问题
I installed python 2.7 alongside my mac. I have a project running using Django v1.9.4.
Unfortunately manage.py runserver
is throwing an error while running failed because it couldn't find module named services.
From a shell:
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
utility.execute()
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 327, in execute
django.setup()
File "/Library/Python/2.7/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Library/Python/2.7/site-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/Library/Python/2.7/site-packages/django/apps/config.py", line 90, in create
module = import_module(entry)
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named services
I'm wondering what should be done here to install this module.
回答1:
It seems that 'services' is your project's module. Maybe you should set the PYTHONPATH environment to make python find your module. If the module is in current directory, you can run the project like this: export PYTHONPATH=.:$PYTHONPATH manage.py runserver
来源:https://stackoverflow.com/questions/39060020/importerror-no-module-named-services-django