Package installation issues
You might encounter a problem when installing a Python package in the project settings or in the Python Package tool window. Eventually, most of the issues are out of IDE control as PyCharm uses the pip package manager to perform the actual installation.
This article provides troubleshooting tips and covers some typical cases.
Install a package using the Terminal
The most viable troubleshooting action is to try installing the problematic package on the selected Python interpreter using the terminal. If you get an identical error message, then the problem is not in the IDE and you should review the rationales and typical cases, or search for a solution on the Internet.
Install a package on a virtual environment
Press Ctrl+Alt+S to open settings and then select
.Expand the list of the available interpreters and click Show All.
Locate the target interpreter and copy the path to the virtual environment.
Open the system terminal (not the PyCharm's built-in one) and run the following commands:
. <venv path>/bin/activate pip install <package name>source <venv path>/bin/activate pip install <package name>
Install a package on a conda environment
If you didn't change the default conda environment name when configuring the interpreter, you can use the project name. Otherwise, do the following:
Press Ctrl+Alt+S and go to
.Expand the list of the project interpreters and scroll it down, then select Show All.
Locate the interpreter, press Rename, and copy the environment name.
Open the system terminal (not the PyCharm's built-in one) and run the following commands:
conda < 4.6
conda >= 4.6
activate <conda env name> conda install <package name>conda activate <conda env name> conda install <package name>conda < 4.6
conda >= 4.6
source activate <conda env name> conda install <package name>conda activate <conda env name> conda install <package name>For more information about activating an environment, refer to conda documentation.
One of the possible failure cases occurs when the target package is not available in the repositories supported by the conda package manager.
Install a package on a system interpreter
To check the path of the currently selected system interpreter that you were trying to install a package on, press Ctrl+Alt+S and go to
.Expand the list of the available interpreters and click Show All.
Locate the interpreter and copy the path.
Open the system terminal (not the PyCharm's built-in one) and run the following commands:
<interpreter path> -m pip install <package name>You might need the admin privileges to install packages on a system interpreter.
Parse the results
Result | Action |
---|---|
The package cannot be installed because the Python version doesn't satisfy the package requirement. | Try to create another Python interpreter that is based on the Python version that meets the requirement. |
The package cannot be installed because you don't have permissions to install it. | Try to install the package using super-user privileges, for example, |
The package cannot be installed because the package is not available in the repository that is supported by the selected package manager. Example: you're trying to install a package that is not available in the conda package manager repositories. | Try to configure another type of Python interpreter for your project and install the package on it. See how to add and modify a Python interpreter in Configure a Python interpreter. |
The package cannot be installed and it matches one of the typical package installation failure cases. | Check the cases and apply related workarounds. |
The package is successfully installed. | File an issue in the PyCharm issue tracker and provide explicit details about the case including all console output, error messages, and screenshots indicating that you tried to install the package on the same interpreter in the terminal and in the project settings or in the Python Packages tool window. |
Review typical cases
Error message | Related package | Workaround | Reference |
---|---|---|---|
| pygame, pysc2 | Installation fails because the package requires SDL, and pip cannot detect it. Try the following commands:
brew install sdl sdl_image sdl_mixer sdl_ttf portmidi;
pip3 install pygame;
pip install pygame
| https://stackoverflow.com/questions/45992243/pip-install-pygame-sdl-h-file-not-found |
| pyaudio | Try to run the following commands using the admin privileges:
pip install pipwin
pipwin install pyaudio
| |
| any package | Install an openssl library by the way specific to your operating system. See the detailed solutions. |