Using IntellijIdea within an existing virtualenv(在现有的 virtualenv 中使用 IntellijIdea)
问题描述
我想在我现有的 python django 项目中使用 Intellij Idea,该项目是在 ubuntu 的虚拟环境中构建的.如何配置 Intellij Idea 以使用虚拟环境的库?
对于PyCharm2018
根据来自 Pycharm 的 .
- 在打开的选择 Python 解释器"对话框中,选择位于虚拟环境文件夹中的所需 Python 可执行文件,然后单击确定.
转到此链接了解更多信息信息.
<小时>对于旧版本:
好吧,我解决了上述问题.我已将 virtualenv 文件夹的 python 添加到项目 sdk 中.需要将 virtualenv 目录的 python(例如 venv/bin/python2.7)添加到 Intellij Idea 项目路径中.示例:需要进入文件>项目结构(intellij Idea)
在 Project SDK 中按 new,然后将新路径添加到 virtualenv 的 python 目录,如下所示:
转到 Modules>Dependencies 并将您的模块 sdk 设置为在此图片上标记的 Python SDK:
点击Django(下图中标记的选项)并设置Django project root
、Settings
、Manage Script代码> 像这样:
现在按 ok 并最终查看项目设置:
现在需要运行项目.
I want to use Intellij Idea within my existing python django project which was built within a virtual environment in ubuntu. How do I configure Intellij Idea to use the libraries of the virtual environment?
ForPyCharm2018
As per documentation from Pycharm:
- In the Project Interpreter page, click and select Add.
In the left-hand pane of the Add Python Interpreter dialog box, select Virtualenv Environment. The following actions depend on whether the virtual environment existed before.
If Existing environment is selected:
- Specify the required interpreter: use the drop-down list, or click Select an interpreter and find one in your file system.
- Select the check-box Make available to all projects, if needed.
Click OK to complete the task.
ForPycharm2016andlater
To add an existing virtual environment to the list of available interpreters
- In the Project Interpreter page, click .
- In the drop-down list, choose Add local.
- In the Select Python Interpreter dialog box that opens, choose the desired Python executable, located inside the virtual environment folder, and click OK.
Go to this link for more information.
ForOlderversions:
Well I solved the above problem. I have added virtualenv folder's python to project sdk. The virtualenv directory's python( for example venv/bin/python2.7) needs to be added to Intellij Idea project path. Example: need to go to file>project structure (intellij Idea)
press new in Project SDK, and add new path to virtualenv's python directory like this:
Go to Modules>Dependencies and set your module sdk to Python SDK which is marked on this picture:
Click on Django (option marked in next the image) and set Django project root
, Settings
,Manage Script
like this:
Now press ok and final look of the Project settings:
Now need to run the project.
这篇关于在现有的 virtualenv 中使用 IntellijIdea的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!