I created a virtual environment (virtualenv env
)and then created a python project for scraping websites. I installed the following using pip...
beautifulsoup4==4.4.1
Django==1.9
psycopg2==2.6.1
wheel==0.24.0
When ever I run the command python manage.py runserver
I am getting the following error a ImportError: No module named flower.views
error ('flower' in the name of my app).
The catch is that when I run the app outside of the virtual environment it works flawlessly, but if I bring it back into the virtual environment it breaks giving me the error state above.
Things I have tried...
1) checked INSTALLED APPS to make sure the app was there
2) tried to python manage.py migrate
to make sure I migrated (got the same error)
3) removed old env
file and created new virtual environment using the virtualenv env
command & subsequently installed all of the previously displayed requirements that I listed above using pip
4) Tried removing and recreating the __init__.py
file in the apps
folder
5) Looked for any similar SO posts regarding my troubles (found nothing).
Let me know if there are any files you would like me to post. I would happily oblige.
答案 0 :(得分:2)
当我进入我的虚拟环境时,显然目录结构会发生变化。
我需要做的就是改变......
from apps.flower.views import Index
to
from views import Index
在我的花卉应用urls.py
档案中。