AttributeError: module ‘datetime’ has no attribute ‘now’

User’s own custom datetime.py module was overriding standard library, the information below is still useful to understand why that would happen. The import algorithm first checks your immediate directory. You can check that modules file path with: print a_module.__file__ Welcome to the wild world of programming. So, I’m not sure I fully understand your question, … Read more

AttributeError while querying: Neither ‘InstrumentedAttribute’ object nor ‘Comparator’ has an attribute

This is because you are trying to access bar from the FooBar class rather than a FooBar instance. The FooBar class does not have any bar objects associated with it–bar is just an sqlalchemy InstrumentedAttribute. This is why you get the error: AttributeError: Neither ‘InstrumentedAttribute’ object nor ‘Comparator’ object associated with FooBar.bar has an attribute … Read more

AttributeError: ‘module’ object has no attribute ‘urlretrieve’

As you’re using Python 3, there is no urllib module anymore. It has been split into several modules. This would be equivalent to urlretrieve: import urllib.request data = urllib.request.urlretrieve(“http://…”) urlretrieve behaves exactly the same way as it did in Python 2.x, so it’ll work just fine. Basically: urlretrieve saves the file to a temporary file … Read more

__getattr__ on a module

There are two basic problems you are running into here: __xxx__ methods are only looked up on the class TypeError: can’t set attributes of built-in/extension type ‘module’ (1) means any solution would have to also keep track of which module was being examined, otherwise every module would then have the instance-substitution behavior; and (2) means … Read more

Why Python 3.6.1 throws AttributeError: module ‘enum’ has no attribute ‘IntFlag’?

It’s because your enum is not the standard library enum module. You probably have the package enum34 installed. One way check if this is the case is to inspect the property enum.__file__ import enum print(enum.__file__) # standard library location should be something like # /usr/local/lib/python3.6/enum.py Since python 3.6 the enum34 library is no longer compatible … Read more