Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any way to force PyCharm to refresh its understanding of a virtual environment, other than quit & restart?

Tags:

pycharm

I'm using PyCharm 3.4.1, and I've configured it to use an interpreter from a Python 3.4 venv.

However, when I do an external "pip install" of additional packages to the venv, PyCharm's code analysis still highlights references as being unsatisfied. (Most recently, after installing a package as editable source.)

Quitting & restarting resolves the issue. But is there any other way to kick/refresh PyCharm's idea of what's available to the venv interpreter?

like image 304
gojomo Avatar asked Sep 10 '14 08:09

gojomo


People also ask

How do I activate the existing virtual environment in PyCharm?

Set an existing virtual environmentPress Ctrl+Alt+S to open the IDE settings and select Project <project name> | Python Interpreter. icon and select Show All. Select the target environment from the list and click OK to confirm your choice.

What is the best environment for PyCharm?

So back to your question, when you create an env in Pycharm, it will ask you which env do you want to create: Virtualenv Environment , Conda Environment , or Pipenv Environment . As for me, I usually choose Pipenv Environment as this env will be bound to the current project and can generate a lock file.


2 Answers

Help > Find Action:

Rescan Available Python Modules and Packages

Available from PyCharm 2020.1.2 (YouTrack Issue)

like image 75
Oliver Sieweke Avatar answered Oct 15 '22 00:10

Oliver Sieweke


I was able to solve this by editing the interpreter path of the environment you are using, then editing it back and applying. Still not perfect, but you don't have to restart PyCharm.

You can edit it in Preferences/Project/Project Interpreter. Click on cog wheel next to the dropdown interpreters.

like image 38
favidavid Avatar answered Oct 15 '22 00:10

favidavid