When creating a new Python project, why would I want to select this option? If I don't select it, what functionality am I missing out on? Would I not be able to import certain Python modules?
-
where did you see this option? – Vishal Singh Mar 08 '20 at 08:48
-
When creating a new Python project and selecting the "Project Interpreter" drop-down menu – Hayden Morgan Mar 08 '20 at 08:49
4 Answers
The other answers aren't quite accurate. The "inherit global site-packages" doesn't "pre-install" or "add packages" into your virtual environment. The settings gives your virtual environment access to the global site-packages.
https://www.jetbrains.com/help/pycharm/creating-virtual-environment.html
Select the Inherit global site-packages checkbox if you want that all packages installed in the global Python on your machine to be added to the virtual environment you're going to create. This checkbox corresponds to the --system-site-packages option of the virtualenv tool.
https://virtualenv.pypa.io/en/16.7.9/reference.html
--system-site-packages Give the virtual environment access to the global site-packages.

- 211
- 2
- 3
It's just an option to pre-install some packages that you're using everytime, or if it doesn't bother you to have extra packages in your local python interpreted
- select it : all packages installed in the global python of your machine will be installed for the interpreter you're going to create in the virtualenv.
- do not select it : the interpreter you're going to create in the virtualenv will just have the basic, like pip, and setuptools, then you can install just what you need
Python global and venv :
The global python, is the one in
/usr/bin
in Linux, or wherever in Windows, this is the main installation of the program, and you can add extra packages usingpip
When you're working on something, you may need only some packages, or specific version so not using the global Python. You can create a virtualenv, or pyenv, that will link a local python to the global one, for the main python functionnality, but the packages will be installed only in the virtualenv (and when using Pycharm, it can install for you the main package into the virtualenv you're creating)

- 53,056
- 7
- 34
- 70
-
Could something similar be done but instead of inheriting site packages from global python its from one virtual environment to another? – MorningGlory Sep 01 '21 at 14:20
-
@MorningGlory I really don't know, look https://www.google.com/search?q=virtualenv+inherit+from+another and search ;) – azro Sep 01 '21 at 16:53
-
Good answer, but I still have a little question. If I select a python in a conda environment as the base interpreter, I think that python should be the global python, not the `/usr/bin` one. Is that correct? – Zhongzheng_11 Sep 05 '21 at 02:55
-
@Zhongzheng_11 the `/usr/bin` is the global one, or one of them, if you have multiple installed. – azro Sep 06 '21 at 06:04
PyCharm uses virtualenv to give your project its own set of packages that is separate from the rest of your system. “Inherit global site packages” means that the packages installed on your computer (outside of the virtual environment) will be added to the virtual environment.

- 707
- 4
- 22
You must understand what is inherit first. Inheritance allow you to use the method field of your parents. So in this case, you are allowed to use the package of your root python environment.

- 97
- 2
- 8