pydev 无法识别 django 的 python 安装
我已经安装了 python 和 django。我知道安装在那里,因为我按照说明安装了它,并且在命令行中我可以执行“导入 python”并且没有崩溃。
当我尝试在 pydev 中创建 django 项目时,出现错误:“未找到 Django”。
问题可能是什么?
I have python installed with django. I know the installation is there because I installed it following the directions and in the command line I can do "import python" and there is no crash.
When I try creating a django project in pydev, I get an error: "Django not found."
What could the problem be?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(10)
我遇到了同样的问题,这就是我在安装 eclipse 后所做的:
(其中有一些 django 文件夹,可能是安装)
然后创建一个 Django 项目应该就可以了。
祝你好运!
I had the same problem and this is what I did just after installing eclipse:
(some django folders were in there, persumably the installation)
Creating a Django project afterwards should be ok.
Good Luck!
进入菜单窗口 ->偏好-> pydev->解释器-Python;并在那里添加Python解释器,如果你在虚拟环境中安装了django,你应该添加虚拟环境的Python解释器;通过单击 new 添加解释器后,您现在应该单击 Apply ,您现在应该看到 PYTHONPATH 中添加到它们之间的所有系统库 Django 。
希望这会有所帮助
go in the menu to window -> preference -> pydev -> Interpreter - Python ; and add the python interpreter there, if you installed the django in a virtual environment you should add the python interpreter of the virtual env ; after adding the interpreter by clicking on new you should now click on Apply , you should see now all the system libs from PYTHONPATH added there between them Django .
hope this will help
Jaffa,
在 python 中安装 Django 之前,您可能已经在 Eclipse 中配置了 python 解释器。
所以你现在要做的就是在 Eclipse 中删除 Python 解释器并再次添加它(现在它已经安装了 Django),一切都应该可以正常工作。
Jaffa,
You might have configured your python interpreter in Eclipse prior to installing Django in python.
So what you have to do now is in Eclipse remove the Python interpreter and add it again (now that it has Django installed) and all should work ok.
我今天遇到了同样的问题,我只是想添加一些注释来帮助人们解决问题。您可以按照上面 antonkeren 的说明进行操作,但有一点需要注意,没有提到。将 django 目录添加到路径后,您必须退出 ECLIPSE 或 APTANA STUDIO。重新启动并尝试创建 django 项目后,它将可以工作。
I was having this same exact problem today, and I just wanted to add some notes to help people out. You can follow the instructions of antonkeren above, but there's one thing to note that was not mentioned. After adding the django directory to the path you must QUIT ECLIPSE OR APTANA STUDIO. After you restart it and try to create a django project it will work.
我自己昨天才偶然发现这一点:Django 一定不能位于系统库中才能使其发挥作用......
I stumbled upon this only yesterday myself: Django must not be among the system libraries for this to function...
我遇到了同样的问题,并通过将 python 主目录添加到 PATH 变量并在 pydev 上重新配置 python 解释器来解决它。
I had the same problem and had solved it by adding the python home directory to the PATH variable and reconfigure the python interpreter on pydev.
在首选项选项中使用自动配置,然后单击应用,然后单击确定。
Use auto config in the preferences option and then click apply and then ok.
如果一切都按照上面所述完成,并且在尝试创建 django 项目时仍然显示“未找到 Django”,请尝试双击 python 脚本文件夹中的“django-admin”python 文件。并尝试创建 django 项目
If everything is done as said above, and still showing "Django not found" while your are trying to create django project, let try to double click 'django-admin' python file that in scripts folder of python. And try to create django project
我想我也遇到了同样的问题,Fedora 上的Eclipse 3.5.2。在我的 PyDev Python 解释器设置中,我有
site-packages/django
文件夹(site-packages/django/bin
,以防万一),但是当我尝试创建 django 项目时,我收到一个错误对话框,显示“似乎所选的解释器没有可用的 Django”。看起来我将不得不使用 Eric4,这很遗憾,因为我根本无法在我的 Windows 设备上运行它!除非我设法理解上面的神秘建议,否则“Django 不能在系统库中才能运行......”
I think I've got the same problem, Eclipse 3.5.2 on Fedora. In my PyDev Python interpreter settings I've got the
site-packages/django
folder (site-packages/django/bin
too, just in case), but when I try to create a django project I get an error dialogue saying "It seems that the selected interpreter does not have Django available". Looks like I'm going to have to use Eric4, which is a pity because I can't get that working at all on my Windows rig!Unless I manage to understand the cryptic advice above, "Django must not be among the system libraries for this to function..."
我今天遇到了同样的问题。我从这些答案中得到了帮助。
但就我而言,它不起作用。
@antonkeren 的答案有一些小修改。
1) 转到首选项。窗口>偏好。
2) 搜索 Pydev
3) 选择 Python 解释器
4) 按快速自动配置
5) 现在下载 www.djangoproject.org/downloads django tar 并在任何位置解压。
6) 现在单击“系统 PYTHONPATH”的“库选项卡”中的文件夹,然后选择提取的 django 项目文件夹位置。
7)点击应用并确定。
之后创建一个Django项目应该就可以了。
干杯...!!
Same problem I have faced today. I took help from these answer.
but in my case it didnt work.
There is small modification in @antonkeren answer.
1) Go to Preferences. Windows > preferences.
2) Search for Pydev
3) Select Python Interpreter
4) Pressed Quick Auto-config
5) now download www.djangoproject.org/downloads django tar and extract on any location.
6) now click on Folder in "Libraries tab" of "System PYTHONPATH" and select your extracted django project folder location.
7) Click on apply and ok.
Creating a Django project afterwards should be ok.
Cheers...!!