Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
300 views
in Technique[技术] by (71.8m points)

python - Configuring PyCharm with existing virtualenv

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

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

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

Any idea what I am missing?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

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

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

Add the right content root

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.

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"

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...