pydev does not recognize django installation

ぃ、小莉子 提交于 2019-12-10 05:08:31

问题


I have python 2.6.1 installed with django 1.3 and PyDev 2.0. I am able to import django and print the version from commandline. However, when I try to create a Django project with pydev or even import django I get an error. When creating the django project, I get "Django not found." error.

I have tried removing and adding the pythong interpreter to rescan the site-packages. I see that django is not available in the Libraries section. I have even tried adding the folder manually and applying the setting.

Am I missing something?

Thanks


回答1:


I had the same problem. I even had django in my System Libs. My solution was to add the same folder to the Project > PyDev-PYTHONPATH > External Libraries:

/usr/local/lib/python2.7/dist-packages

Before that I tried to reinitiate the interpreter, but no luck. The above solution was the only one the worked for me.




回答2:


Probably the PYTHONPATH configured in your interpreter is not correct...

I.e.: if you have a structure with

/my/path/django
/my/path/django/__init__.py

you have to make sure that

/my/path 

is added to the PYTHONPATH (and /my/path/django is NOT)

Another thing to note is that right after installing Django, you just have to do a refresh in your interpreter so that it's recognized (go to the interpreter preferences page, press 'apply' and choose the interpreters to be re-analyzed -- there are already plans to make this automatic in one of the upcoming releases, but right now you have to do that manually because the interpreter is analyzed when you configure it and 'set in stone').




回答3:


I had the exact same problem - only with later versions of the different softwares: Python 3.3.2 and Django 1.5.1 under Eclipse with PyDev 2.7.5. I solved the problem differently:

I simply copied the complete Django 1.5.1 folder into the Python "Resources" folder /System/Library/Frameworks/Python.framework/Versions/3.3/Resources/Django-1.5.1 and applied the interpreter again.

This worked right away, letting me create a Django project from within the eclipse. Hope this helps.

Frank




回答4:


If you have installed Django by pip as Django site mentions1, and you can find django files in /python/Lib/site-packages/django path, you do not need to configure the interpreter manually. You can remove the chosen interpreter and select Quick-Auto Config.



来源:https://stackoverflow.com/questions/5749871/pydev-does-not-recognize-django-installation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!