在现有 virtualenv 中使用 IntellijIdea [英] Using IntellijIdea within an existing virtualenv

查看:30
本文介绍了在现有 virtualenv 中使用 IntellijIdea的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我现有的 python django 项目中使用 Intellij Idea,该项目是在 ubuntu 的虚拟环境中构建的.如何配置 Intellij Idea 以使用虚拟环境的库?

解决方案

对于 PyCharm 2018

根据 Pycharm 的.

  • 在下拉列表中,选择添加本地.
    1. 在打开的选择 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 rootSettingsManage Script像这样:

    现在按确定并最终查看项目设置:

    现在需要运行项目.

    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?

    解决方案

    For PyCharm 2018

    As per documentation from Pycharm:

    1. In the Project Interpreter page, click and select Add.
    2. 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.

    3. If Existing environment is selected:

      1. Specify the required interpreter: use the drop-down list, or click Select an interpreter and find one in your file system.
      2. Select the check-box Make available to all projects, if needed.

    4. Click OK to complete the task.


    For Pycharm 2016 and later

    To add an existing virtual environment to the list of available interpreters

    1. In the Project Interpreter page, click .
    2. In the drop-down list, choose Add local.

    1. 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.


    For Older versions:

    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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆