Codrspace / codrspace

The blogging platform for coders.
http://codrspace.com
Other
35 stars 13 forks source link

ImportError on installation #60

Closed akalenuk closed 10 years ago

akalenuk commented 10 years ago

I'm following installation guideline in order to install CodrSpace with no Virtualenv. On the step when I do 'python manage.py syncdb', I get the following error:

ImportError: Could not import settings 'codrspace.settings' (Is it on sys.path?): No module named settings

It's raised by django/conf/__init__ after trying mod = importlib.import_module(self.SETTINGS_MODULE) in initing the Settings class.

So far I tried to follow the message literally and added the path to settings.py to a sys.path. It didn't help.

akalenuk commented 10 years ago

Well, I kind of made it work, but there's still something not right there. Settings module gets imported twice. Once in manage.py by this line:

12: import settings

And then in django/conf/init.py when trying to do 'fetch_command' in 'utility.execute()' that leads to reinitializing the Settings class:

132: mod = importlib.import_module(self.SETTINGS_MODULE)

At this point self.SETTINGS_MODULE is set to codrspace.settings and sys.path is modified by the very settings imported earlier to include APPS_PATH, which points to '~/codrspace/apps'.

So copying 'settings.py' to the '~/codrspace/apps/codrspace' kind of solves the problem. Meaning of course running servers. But there's another problem then. There's two copies of settings and you can't remove any of them.

durden commented 10 years ago

Are you running manage.py while in the top-level repo directory? The settings.py in the top-level directory should put the 'codrspace app' on your sys.path. You shouldn't have to do anything strange like copying settings.py around.

Also could you please post what versions of Python, django, and which branch of codrspace you're using?

I've run the exact same steps in the install on a completely new virtualenv and syncdb worked. Maybe something is messing up because you have all the requirements installed into your main Python sys.path?

akalenuk commented 10 years ago

Yes, I am running manage.py from top-level directory. And yes, settings.py do add codrspace app to my sys.path. The problem is, coddrspace app is ~/codrspace/apps/codrspace and settings are in ~/codrspace.

Python version is 2.7.3, Django is (1, 5, 1, final, 0). It is installed by pip from codrspace dependencies, I've had 1.3 from Ubuntu repositories before that. And I'm using master branch.

My sys.path is at first exactly this:

/usr/local/lib/python2.7/dist-packages/setuptools-3.4.4-py2.7.egg
/usr/local/lib/python2.7/dist-packages/pip-1.5.4-py2.7.egg
/home/akalenuk/codrspace/src/frappy
/usr/lib/python2.7
/usr/lib/python2.7/plat-linux2
/usr/lib/python2.7/lib-tk
/usr/lib/python2.7/lib-old
/usr/lib/python2.7/lib-dynload
/usr/local/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages/PIL
/usr/lib/python2.7/dist-packages/gst-0.10
/usr/lib/python2.7/dist-packages/gtk-2.0
/usr/lib/python2.7/dist-packages/ubuntu-sso-client
/usr/lib/python2.7/dist-packages/ubuntuone-client
/usr/lib/python2.7/dist-packages/ubuntuone-control-panel
/usr/lib/python2.7/dist-packages/ubuntuone-couch
/usr/lib/python2.7/dist-packages/ubuntuone-installer
/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol
/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode

That's including of course the empty string at the beginning. Well, it does include dependencies.

After importing settings.py the first time it became:

/home/akalenuk/codrspace/apps

/usr/local/lib/python2.7/dist-packages/setuptools-3.4.4-py2.7.egg
/usr/local/lib/python2.7/dist-packages/pip-1.5.4-py2.7.egg
/home/akalenuk/codrspace/src/frappy
/usr/lib/python2.7
/usr/lib/python2.7/plat-linux2
/usr/lib/python2.7/lib-tk
/usr/lib/python2.7/lib-old
/usr/lib/python2.7/lib-dynload
/usr/local/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages/PIL
/usr/lib/python2.7/dist-packages/gst-0.10
/usr/lib/python2.7/dist-packages/gtk-2.0
/usr/lib/python2.7/dist-packages/ubuntu-sso-client
/usr/lib/python2.7/dist-packages/ubuntuone-client
/usr/lib/python2.7/dist-packages/ubuntuone-control-panel
/usr/lib/python2.7/dist-packages/ubuntuone-couch
/usr/lib/python2.7/dist-packages/ubuntuone-installer
/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol
/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode

Maybe it has something to do with virtualenv. I didn't install with it. I'd try reinstalling with virtualenv just to exclude the possibility.

durden commented 10 years ago

You might want to change the directory where you cloned the repo to 'codrspace_app' instead of 'codrspace' as the install suggests. I think the problem is you are running in a codrspace directory and then the settings.py puts 'apps/codrspace' on your sys.path automatically, see here for how that works:

https://github.com/Codrspace/codrspace/blob/master/settings.py#L7

Those lines should put 'apps/codrspace' on your path so you never have to think of the sys.path, etc. after starting up.

akalenuk commented 10 years ago

Aha! Yes, that's it. Who would have thought :-) Thanks!