eclipse pydev 无法使用 django 识别 python 安装

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3939877/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 15:11:33  来源:igfitidea点击:

pydev not recognizing python installation with django

pythondjangoeclipsepydev

提问by tipu

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.

我用 django 安装了 python。我知道安装在那里,因为我按照说明安装了它,并且在命令行中我可以执行“导入 python”并且没有崩溃。

When I try creating a django project in pydev, I get an error: "Django not found."

当我尝试在 pydev 中创建 django 项目时,出现错误:“找不到 Django”。

What could the problem be?

可能是什么问题?

采纳答案by mouad

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 newyou should now click on Apply, you should see now all the system libs from PYTHONPATH added there between them Django .

进入菜单窗口 -> 首选项 -> pydev -> 解释器 - Python;并在那里添加python解释器,如果你在虚拟环境中安装了django,你应该添加虚拟环境的python解释器;通过单击new添加解释器后,您现在应该单击Apply,您现在应该看到来自 PYTHONPATH 的所有系统库添加到它们之间 Django 。

hope this will help

希望这会有所帮助

回答by antonkeren

I had the same problem and this is what I did just after installing eclipse:

我遇到了同样的问题,这就是我在安装 eclipse 后所做的:

  • Preferences > Interpreter Python
  • Pressed Auto-config
  • Selected /Library/Python/x.x/site-packages, which was not selected (some django folders were in there, persumably the installation)
  • Clicked apply / OK
  • 首选项 > Python 解释器
  • 按下自动配置
  • 选择了/Library/Python/xx/site-packages,没有选择(一些django文件夹在那里,大概是安装)
  • 单击应用/确定

Creating a Django project afterwards should be ok.

之后创建一个 Django 项目应该没问题。

Good Luck!

祝你好运!

回答by KeepItCool

Jaffa,

雅法,

You might have configured your python interpreter in Eclipse prior to installing Django in python.

在 python 中安装 Django 之前,您可能已经在 Eclipse 中配置了 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.

所以你现在要做的是在 Eclipse 中删除 Python 解释器并再次添加它(现在它已经安装了 Django),一切都应该正常工作。

回答by shawnwall

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.

我今天遇到了同样的问题,我只是想添加一些注释来帮助人们解决问题。您可以按照上述 antonkeren 的说明进行操作,但有一点需要注意,但未提及。将 django 目录添加到路径后,您必须退出 ECLIPSE 或 APTANA STUDIO。重新启动它并尝试创建一个 django 项目后,它将起作用。

回答by cpt_ahag

I stumbled upon this only yesterday myself: Django must notbe among the system libraries for this to function...

我自己昨天才偶然发现了这一点:Django不能在系统库中才能发挥作用......

回答by cpt_ahag

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.

我遇到了同样的问题,并通过将 python 主目录添加到 PATH 变量并在 pydev 上重新配置 python 解释器来解决它。

回答by hassanadnan

Use auto config in the preferences option and then click apply and then ok.

在首选项选项中使用自动配置,然后单击应用,然后确定。

回答by sibby

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

如果一切都按照上面说的做了,并且在您尝试创建 django 项目时仍然显示“找不到 Django”,让我们尝试双击 python 脚本文件夹中的“django-admin”python 文件。并尝试创建 django 项目

回答by Jaffa McNeill

I think I've got the same problem, Eclipse 3.5.2on Fedora. In my PyDev Python interpreter settings I've got the site-packages/djangofolder (site-packages/django/bintoo, 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..."

我想我在Fedora上遇到了同样的问题,Eclipse 3.5.2。在我的 PyDev Python 解释器设置中,我有文件夹(也是,以防万一),但是当我尝试创建一个 django 项目时,我收到一个错误对话框,提示“似乎所选的解释器没有可用的 Django”。看起来我将不得不使用 Eric4,这很遗憾,因为我根本无法在我的 Windows 设备上使用它!除非我设法理解上面的神秘建议,否则“Django 不能在系统库中才能发挥作用......”site-packages/djangosite-packages/django/bin

回答by Ronnie

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.

@antonkeren 的答案有一些小的修改。

1) Go to Preferences. Windows > preferences.

1) 转到首选项。Windows > 首选项。

2) Search for Pydev

2)搜索Pydev

3) Select Python Interpreter

3)选择Python解释器

4) Pressed Quick Auto-config

4) 按下快速自动配置

5) now download www.djangoproject.org/downloads django tar and extract on any location.

5) 现在下载 www.djangoproject.org/downloads django tar 并在任何位置解压。

6) now click on Folder in "Libraries tab" of "System PYTHONPATH" and select your extracted django project folder location.

6)现在单击“系统PYTHONPATH”的“库选项卡”中的文件夹,然后选择解压缩的django项目文件夹位置。

7) Click on apply and ok.

7)点击应用并确定。

Creating a Django project afterwards should be ok.

之后创建一个 Django 项目应该没问题。

Cheers...!!

干杯...!!