使用现有的 virtualenv 配置 PyCharm [英] Configuring PyCharm with existing virtualenv

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

问题描述

我正在尝试使用现有的 virtualenv 设置运行 PyCharm.我已将我的 PyCharm 项目指向以下路径中现有 virtualenv ~/.virtualenvs/myproj/中的 python 解释器

I am trying to get PyCharm running using existing virtualenv setting. I have pointed my PyCharm project to python interpreter in existing virtualenv ~/.virtualenvs/myproj/ in the following path

文件 -> 默认设置 -> 默认项目 -> Python 解释器

File -> Default Settings -> Default Project -> Python Interpreter

项目运行良好,但编辑器在作为 virtualenv 的一部分安装的包上仍然显示红色.

the project runs fine but the editor is still glowing RED on packages installed as part of the virtualenv.

知道我错过了什么吗?

推荐答案

要为您的项目正确运行 PyCharm,您需要正确设置 Python Interpreter 和 Python Structure.

To run PyCharm properly for your project, you need to set Python Interpreter and Python Structure correctly.

我已经正确设置了 Python 解释器,但错过了 Python 结构.

I had set Python Interpreter correctly but missed out on Python Structure.

转到 Pycharm->Preferences->your_project->Project Structure

Go to Pycharm->Preferences->your_project->Project Structure

添加正确的内容根

它与您的工作目录无关,您可以在调试/运行配置中单独设置

It has nothing to do with your working directory which you can set separately in your debug/run configuration

也不要忘记添加你需要的环境变量,你应该很高兴.

also don't forget to add environment variables you need and you should be good to go.

对于 Intellij Idea 2016.2,以下是添加安装在 virtualenv 中的站点包的路径文件 -> 项目结构 -> 来源 -> 使用 + 按钮并添加为来源"

For Intellij Idea 2016.2, following is the path to add site-packages installed in virtualenv File -> Project Structure -> Sources -> "Use + button and add as Sources"

如果隐藏目录可见,您可以更改视图设置或将路径复制粘贴到 virtualenv 中的站点包

if hidden directory may is be visible, you may either change your view settings or copy paste the path to site-packages in virtualenv

这篇关于使用现有的 virtualenv 配置 PyCharm的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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