PyCharm 2023.2 Help

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

  1. Press Control+Alt+S to open the IDE settings and then select Project <project name> | Python Interpreter.

  2. Expand the list of the available interpreters and click Show All.

    Show all available interpreters
  3. Locate the target interpreter and press edit interpreter.

    Discover the interpreter path for the selected venv

    Copy or memorize the path of the virtual environment and close the dialogs.

  4. Open the terminal and run the following commands:

    source <venv path>/bin/activate pip install <package name>
    Installing a Python package on a virtual environment
  5. Inspect and parse the results.

Install a package on a Conda environment

  1. Open the terminal 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.

    Installing a Python package on a virtual environment

    One of the possible failure cases occurs when the target package is not available in the repositories supported by the Conda package manager.

    Fail to install a package on a Conda environment
  2. Inspect and parse the results.

Install a package on a system interpreter

  1. To check the path of the currently selected system interpreter that you were trying to install a package on, press Control+Alt+S and go to Project: <project name> | Python Interpreter.

  2. Expand the list of the project interpreters and scroll it down, then select the Show All item.

    Selected Python interpreter
  3. Locate the interpreter and press edit interpreter.

    Discover the interpreter path for the selected venv

    Copy or memorize the path of the environment and close the dialogs.

  4. Open the terminal and run the following commands:

    cd <interpreter path> -m pip install <package name>
    Installing a Python package on a system environment

    You might need the admin privileges to install packages on a system interpreter.

  5. Inspect and parse the results.

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, sudo pip install <package name>.

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

fatal error: 'SDL.h' file not found

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

Cannot open include file: 'portaudio.h'

pyaudio

Try to run the following commands using the admin privileges:

pip install pipwin pipwin install pyaudio

https://stackoverflow.com/questions/51992375/how-to-fix-installation-issues-for-pyaudio-portaudio-fatal-error-c1083-canno

https://www.programmersought.com/article/5816775591/

SSL module in Python is not available

any package

Install an openssl library by the way specific to your operating system. See the detailed solutions.

https://stackoverflow.com/questions/41328451/ssl-module-in-python-is-not-available-when-installing-package-with-pip3/54932141#54932141.

Last modified: 08 September 2023