I'm new to PyCharm and the idea of "virtual environments". I'm not sure where else to post this question, so hoping it'll help others as well in the future.
Right now, if I run pip install x
, x gets installed to the python site-packages directory, and I can use that package in any script by simply importing it at the beginning.
But now that it's installed that way, it's meaningless when you create a new pipenv in PyCharm, right? Each new environment you create, you need to run pip install x
again, and again in any new environments from there, then you can make use of them. Does this really install the same package to your computer over and over again in each environment's package? Seems inefficient.
How could we just make use of already installed, global packages on your computer? For example, running pip install tensorflow
every time you want to create a new environment is time consuming and (I'm assuming) also a waste of disk space? Unless I'm misunderstanding the concept.
You can add global site-packages to a new virtual environment with:
python3 -m venv venv-name --system-site-packages
or if you want to create a virtual env through PyCharm go to
File > Settings... > Project > Python interpreter > Add...
and check Inherit global site-packages when creating a new environment.