I'm using django-piston and running into the following problem when running the manage.py syncdb command:
Traceback (most recent call last):
File "./manage.py", line 13, in <module>
execute_manager(settings)
File "/home/appfirst/django/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
............ lines ommitted ...........
File "/home/appfirst/django/django/utils/translation/trans_real.py", line 176, in translation
default_translation = _fetch(settings.LANGUAGE_CODE)
File "/home/appfirst/django/django/utils/translation/trans_real.py", line 160, in _fetch
apppath = os.path.join(os.path.dirname(app.__file__), 'locale')
AttributeError: 'module' object has no attribute '__file__'
In my development environment, I don't have this problem. There I have my python path set to include the django-piston directory. On production, I installed piston by compiling it to an rpm (python setup.py bdist --format=rpm) and installing it as an egg in /usr/lib/python2.6/site-packages/. This means that in development, I can do
>>> import piston
>>> piston.__file__
/some/file/path/here
But on production I get
>>> import piston
>>> piston.__file__
AttributeError: 'module' object has no attribute '__file__'
Does anyone know a way around this?
Looks like this is a known issue with Piston 0.2.3. You could apply this patch or just use version 0.2.2 by installing it as so:
pip install django-piston==0.2.2
I had the same issue, not sure what caused it, but to fix it, I uncommented the piston app out of my INSTALLED_APPS in settings, and it started working again, so it was something to do with loading piston. I'm going to remove piston from my site-packages directory and try to reload it, and see if that helps.
Also, while trying to find the answer to my question I came across a few sites with similar issues.
This site describes an issue related to __init__.py missing.
http://www.willmer.com/kb/2007/12/attributeerror-module-object-has-no-attribute-blah/
This site describes circular imports as an issue.
http://www.answermysearches.com/python-fixing-module-object-has-no-attribute/333/
And another one that I can't find, mentioned something about not being able to load the files correctly from an app installed as an egg.
Related
I get a warning message while trying to create exectable file using pyinstaller. This warning appeared after installing Pillow. Previously i nevre got any warnings and was able to make it through.
the warning i get by pyinstaller is:
7314 INFO: Analyzing main.py
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PyInstaller-2.1.1dev_-py2.7.egg/PyInstaller/hooks/hook-PIL.Image.py:14: RuntimeWarning: Parent module 'PyInstaller.hooks.hook-PIL' not found while handling absolute import
from PyInstaller.hooks.shared_PIL_Image import *
Also when i tried to run the executable's exe/consol version of my code that lies inside the dist folder created by the pyinstaller (dist/main/main), these are displayed..
Traceback (most recent call last):
File "<string>", line 26, in <module>
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PyInstaller-2.1.1dev_-py2.7.egg/PyInstaller/loader/pyi_importers.py", line 276, in load_module
exec(bytecode, module.__dict__)
File "/Users/..../build/main/out00-PYZ.pyz/PIL.PngImagePlugin", line 40, in <module>
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PyInstaller-2.1.1dev_-py2.7.egg/PyInstaller/loader/pyi_importers.py", line 276, in load_module
exec(bytecode, module.__dict__)
File "/Users/..../build/main/out00-PYZ.pyz/PIL.Image", line 53, in <module>
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PyInstaller-2.1.1dev_-py2.7.egg/PyInstaller/loader/pyi_importers.py", line 276, in load_module
exec(bytecode, module.__dict__)
File "/Users/..../build/main/out00-PYZ.pyz/FixTk", line 74, in <module>
OSError: [Errno 20] Not a directory: '/Users/.../dist/main/tcl'
logout
[Process completed]
so, i tried by uninstalling pillow, installing tk tcl dev version. And then installed pillow. Even that didnt helped.
I also tried reinstalling pyinstaller,. didnt help too
Update 1:
It seems Pyinstaller.hooks.hook-PIL.py file was missing in the Pyinstaller/hooks directory. And it was missing on all platforms(Mac, windows and linux). This is the warning/error message that i get on windows, which is the same i got on mac and on linux.
Later i found a link which said, its just to need Python import machinery happy. so i created as said so. Then i dont get the same error on all platforms, But on mac i still get the PILImagePlugin,Image and FixTk errors
Solution for tcl:
I found what was going wrong,.. Every problem that i faced on OSX was the OS itself(exactly the macport). Python by default comes with the mac OS. And this version of python may be useful for just learning basic python, but is not suitable for Development purpose.
Installing brew's python helped. I followed this SO link. After doing these i was still getting errors. Later i had to change the paths on /etc/paths. Basically rearranging them should work. But still then i wasn't getting it right.
Then i had to change the .bash_profile, which worked for most users, But still i was getting mac's version of python and pip, not the brews version of python.
Finally i had to restart the machine for a couple of times and do the /etc/paths and .bash_profile steps repeatedly to get the system wide effect to accept brews version of python and pip
Solution for PIL:
just adding a file called hook-PIL.py with an empty content would serve the purpose. I found a link which was having the hook files content of pyinstaller.
The location to create
for mac : /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PyInstaller-2.1.1dev_-py2.7.egg/PyInstaller/hooks/ Actually for mac this step wouldn’t be required. When we install python through brew and change the path, everything that you try to install later either through pip install or from source packages tend to choose a different path. And everything will be taken care of.
for windows:C:\Python27\lib\site-packages\PyInstaller-2.1.1.dev0-py2.7.egg\PyInstaller\hooks
**Please check if this is a valid path on your machine before creating the file and then create the file. And im not sure or i don't know if just adding an empty file is the right way. But it worked for me
I'm not sure which log to look at, but in general, all the errors are the same as this paste. I recently upgraded my client machine to Python version 2.7.8, from 2.7.7. The app runs locally.
E 22:20:58.694
Traceback (most recent call last):
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 302, in _LoadHandler
raise err
ImportError: <module 'blog' from '/base/data/home/apps/s~eminent-augury-789/1.380687153152922933/blog.pyc'> has no attribute application
It didn't work under 2.7.7, I was getting the same error. I created another project, with a different project id, and it works. I'm guessing that the app.yaml file was corrupt and I just couldn't find the problem. I upgraded app engine before I started this. I use VIM, for editing. I used the same project id for different projects, just changed the version number, not sure if that was the problem, either. I don't know how to cut and paste in code samples, they get formatted differently, let me work on that and I'll paste the app.yaml file in.
I used easy_install to install pip, pip to install django, virtualenv, and virtualenvwrapper.
I have just returned to it a few weeks later and django does not seem to work anymore, but more concerning is I can't start the process over again as easy_install is returning the following error:
Traceback (most recent call last):
File "/usr/bin/easy_install-2.7", line 10, in <module>
load_entry_point('setuptools==0.6c12dev-r88846', 'console_scripts', 'easy_install')()
File "/Library/Python/2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 318, in load_entry_point
File "/Library/Python/2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 2220, in load_entry_point
ImportError: Entry point ('console_scripts', 'easy_install') not found
After a good evening of hunting I am stumped as to how to resolve this.
You seem to have a version conflict; note the setuptools-0.6c11-py2.7.egg path, but the /usr/bin/easy_install-2.7 script wants to load 0.6c12dev-r88846 instead.
The latter is a development version; it has the revision number of a subversion repository embedded in the version (dev-r88846).
I suspect you have two python installations; one is the system version (in /System/Library and the other is installed with the python installer into /Library/, and the stub script in /usr/bin/ may be installed with the system python.
If so, there'll be another copy of the stub at /Library/Python/2.7/bin/easy_install-2.7, which should work correctly.
I had the same issue, eventually ended up running the 2.7.3 easy_install by
/opt/python2.7.3/bin/easy_install which worked fine
I'm setting up a simple db using Django and I got the above error when running 'python manage.py syncdb'
Is this a problem in manage.py or my .db file? Suggestions for how to resolve?
EDIT: Adding full traceback
Traceback (most recent call last):
File "manage.py", line 14, in <module>
execute_manager(settings)
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 252, in fetch_command
app_name = get_commands()[subcommand]
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 101, in get_commands
apps = settings.INSTALLED_APPS
File "/Library/Python/2.7/site-packages/django/utils/functional.py", line 276, in __getattr__
self._setup()
File "/Library/Python/2.7/site-packages/django/conf/__init__.py", line 42, in _setup
self._wrapped = Settings(settings_module)
File "/Library/Python/2.7/site-packages/django/conf/__init__.py", line 139, in __init__
logging_config_func(self.LOGGING)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/config.py", line 776, in dictConfig
dictConfigClass(config).configure()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/config.py", line 562, in configure
'filter %r: %s' % (name, e))
ValueError: Unable to configure filter 'require_debug_false': Cannot resolve 'django.utils.log.CallbackFilter': No module named CallbackFilter
I had the same problem
Go to your settings.py and find the LOGGING settings
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.CallbackFilter',
'callback': lambda r: not DEBUG
}
},
See the CallbackFilter there? Remove the whole 'filters' key. This happened because I tried to use the same settings.py file across 2 different Django versions. If you use djangoadmin.py startproject you get a valid settings.py file.
Please double check if the django version 1.3.1 you have is the most recent one, because this is a bug in Django.
To avoid such situations, I recommend to use virtualenv: How to create multiple Django environments using virtualenv
If you have the most recent version and still facing the issue, please update this bug: Ticket #16568 require_debug_false does not work as intended (backward incompatible)
The bug also has a simple solution:
Remove require_debug_false from global_settings.py (since it does
not work) and force everyone to copy/paste the default LOGGING snippet
to their settings
Answer posted by django developer andreas_pelme here, this is not a bug and if correct version of django is installed, it should work fine.
~ $ mkvirtualenv t16568-regression
New python executable in t16568-regression/bin/python
Installing setuptools............done.
Installing pip...............done.
virtualenvwrapper.user_scripts creating /Users/andreas/.virtualenvs/t16568-regression/bin/predeactivate
virtualenvwrapper.user_scripts creating /Users/andreas/.virtualenvs/t16568-regression/bin/postdeactivate
virtualenvwrapper.user_scripts creating /Users/andreas/.virtualenvs/t16568-regression/bin/preactivate
virtualenvwrapper.user_scripts creating /Users/andreas/.virtualenvs/t16568-regression/bin/postactivate
virtualenvwrapper.user_scripts creating /Users/andreas/.virtualenvs/t16568-regression/bin/get_env_details
[t16568-regression] ~ $ pip install django==1.3.1
Downloading/unpacking django==1.3.1
Downloading Django-1.3.1.tar.gz (6.5Mb): 6.5Mb downloaded
Running setup.py egg_info for package django
Installing collected packages: django
Running setup.py install for django
changing mode of build/scripts-2.7/django-admin.py from 644 to 755
changing mode of /Users/andreas/.virtualenvs/t16568-regression/bin/django-admin.py to 755
Successfully installed django
Cleaning up...
[t16568-regression] ~ $ cd code/
[t16568-regression] ~ $ django-admin.py startproject foo
[t16568-regression] ~ $ cd foo/
[t16568-regression] ~/foo $ python manage.py shell
In [1]: import django; django.get_version()
Out[1]: '1.3.1'
I have found the prolem. If we have worked with eclipse PyDev and create project into eclipse - we have incorrect project structure.
To solve this problem we need to create project in command line with manage.py startproject myprojectname and in eclipse create new Django project and specify older with already created project via command line tool.
Best regards,
Anton.
Have you tried re-installing django? If not, I think this is a great oportunity to start using virtual env.
There is a class called CallbackFilter in
/usr/local/lib/python2.6/dist-packages/django/utils/dictconfig.py
The fact that you can't read it, means either is not there or your python_path is not well configured, but since you can read other django stuff that is not probably the case.
I had the same problem, and in my case it was due to running manage.py using sudo, which ignores virtual env. There is a solution for this at this thread.
I had the same problem. I would say that the source of the problem is that your "setting.py" was created with a different Django version that your current version. If you dont know what version you have, I recommend you to start a new project in order to have a setting.py with your current Django version.
If you know the Django version that you used to create the project, you can easily install it again with the next command ( example Django version 1.4.5)
pip install Django==1.4.5
I hope this can help.
Hy,
Trying to use qooxdoo with debian lenny.
qooxdoo sdk 1.2
create-application.py ok but I've got a problem with generate.py :
/demo/qooxdoo/hello1$ ./generate.py source-all
Traceback (most recent call last):
File "/demo/qooxdoo-1.2-sdk/tool/bin/generator.py", line 26, in <module>
from generator.Generator import Generator
File "/demo/qooxdoo-1.2-sdk/tool/bin/Generator.py", line 31, in <module>
#import warnings
File "/demo/qooxdoo-1.2-sdk/tool/bin/Generator.py", line 31, in <module>
#import warnings
ImportError: No module named code.Class
I do think I'm missing some debian packages
Do please help me. Ta.
This stack trace is a tad weird. For a basic thing, the referenced code line (Generator.py:31) imports from "generator.code.Class", and the ImportError indicates that it doesn't find the "code" subpackage under "generator". But the "#import warnings" line is actually generator.py line 31, as if it would be mixing generator.py and Generator.py.
This is furthered by the fact that the stack trace references /demo/qooxdoo-1.2-sdk/tool/bin/Generator.py, which should really be /demo/qooxdoo-1.2-sdk/tool/pylib/generator/Generator.py
I don't have a lenny handy to check if the package itself is alright, but I get the feeling there is some basic flaw with how the qooxdoo SDK is installed on your machine.
I recommend that you simply download the qooxdoo-1.2-sdk from sourceforge and unpack it to a suitable directory. Then re-run the create-application.py from this package to create a new skeleton, or edit the config.json of your existing skeleton so that the QOOXDOO_PATH macro points to the new SDK. Then you should be all set.
I agree with zamnut6. I've had the same problem when I extracted the qooxdoo SDK package on a a virtualbox shared HFS filesystem. The problem is something to do with file name casing incompatibility between two file systems.
Extracting the SDK on a normal Linux directory (if your development environment is Linux) should solve this issue.
I ran into this problem too when I had unpacked the zip file in a virtual box shared directory (host XP, guest Ubuntu), the share caused this issue when I ran ./generate.py source within the shared directory.
When I unpacked the zip to a normal Linux directory, I had no problems.