PyCharm 2024.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 Ctrl+Alt+S to open 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 copy the path to the virtual environment.

    Discover the interpreter path for the selected venv
  4. Open the system terminal (not the PyCharm's built-in one) and run the following commands:

    source <venv path>/Scripts/activate pip install <package name>
    Installing a Python package on a virtual environment
    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. 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 Project: <project name> | Python Interpreter.

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

    • Locate the interpreter, press Rename Rename, and copy the environment name.

  2. 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.

    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
  3. 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 Ctrl+Alt+S and go to Project: <project name> | Python Interpreter.

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

    Show all available interpreters
  3. Locate the interpreter and copy the path.

    Discover the interpreter path for the selected venv
  4. Open the system terminal (not the PyCharm's built-in one) and run the following commands:

    <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: 26 May 2024