I've been developing a Django app for weeks locally on OSX 10.6.3. Recently, I rebooted my machine and went to start my development environment up.
Here's the error:
cm:myApp cm$ python manage.py runserver
Traceback (most recent call last): File "manage.py", line 11, in execute_manager(settings) File "/Library/Python/2.6/sit开发者_开发技巧e-packages/django/core/management/init.py", line 360, in execute_manager setup_environ(settings_mod) File "/Library/Python/2.6/site-packages/django/core/management/init.py", line 343, in setup_environ project_module = import_module(project_name) File "/Library/Python/2.6/site-packages/django/utils/importlib.py", line 35, in import_module import(name) ImportError: No module named myapp
I'm pretty new to Django / Python.
Digging around, it's possible that this might be due to MacPorts. Initially, I had a rough time getting Django up and running and I no longer remember if I'm using the Django from a MacPorts install or from easy_install. How do I tell? (I'd prefer not to reinstall everything).
Also, why is the camel casing in my app name gone in the ImportError message? When I search for "myapp" in my django project, I don't find it without camelcase anywhere.
And what causes MacPorts to work for a while but then break?
As a few other details, from settings.py:
INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.admin', 'south', 'registration', 'pypaypal', 'notifier', 'myApp.batches', )
To tell where you're currently running Django from, open up a Python shell and do:
import django
print django.__path__
which should show you the path to the Django directory.
You might also want to do this from with the Python shell:
import sys
print sys.path
This should show you all the directories on the current PythonPath, which might help in your debugging.
Okay, so this is very bizarre and I don't know what happened... but here's what fixed:
- I open terminal and bash isn't recognizing any commands (python, vi, etc)
- I restart machine, still not recognizing any commands
- I look at my $PATH and /usr/bin is missing
- I add /usr/bin to $PATH
- I open vi and modify my profile to add /usr/bin
- vi works, python works
- python manage.py runserver works
How did /usr/bin get removed from my bash profile?
精彩评论