PyCharm 2024.3 Help

Troubleshooting PyCharm

While working with PyCharm, you might encounter some warning or error messages. This chapter provides the list of the known problem solutions and workarounds.

You can also find the recommendations for troubleshooting and performing basic diagnostics of your working environment.

Reported Problem

Possible cause

Solution

Project Settings

A Python interpreter is marked as unsupported in the list of available interpreters in Preferences/Settings | Project | Python Interpreter.

The Python version of the marked interpreter is outdated and it is not supported in PyCharm

You can delete the unsupported interpreter from the list of the available interpreters. For more information about the supported Python versions, refer to Python Support.

Code Editing

PyCharm Editor restricts code editing.

You have installed the IdeaVim plugin and thus enabled the vim editing mode.

Deselect Vim Emulator on the Tools menu. See Using Vim Editor Emulation in PyCharm for more details.

Python code is not highlighted in the Editor.

The PY files are associated with the text file format.

In the Settings dialog (Ctrl+Alt+S) , navigate to Editor | File Types, select Text from the Recognized File Type list, select *.py from the File Name Patterns list, and click Remove.

Code Completion

Code completion action is not available.

Power Save Mode is enabled.

From the main menu, choose File and clear the Power Save Mode checkbox.

Your file doesn't reside in a content root , so it doesn't get the required class definitions and resources needed for code completion.

Restructure your sources files.

A file containing classes and functions that you want to appear in the completion suggestion list is a plain text file.

Reconsider and modify (if needed) the format of your source files.

Debugging

Cannot debug a Docker run/debug configuration; the Debug action is not available.

PyCharm provides debugging for Python run/debug configurations.

Configure a Docker-based interpreter and debug your Python script in a Docker container.

Python Debugger hangs when debugging Gevent code.

Gevent compatibility mode is not enabled.

In the Settings dialog (Ctrl+Alt+S) , navigate to Build, Execution, Deployment | Python Debugger and select the Gevent compatible checkbox.

Some import errors are reported in your PyQt code.

PyQt is installed on the interpreter but is not imported in the application code.

In the Settings dialog (Ctrl+Alt+S) , navigate to Build, Execution, Deployment | Python Debugger, and clear the PyQt compatible checkbox in the . This mode is enabled by default.

Debugging process is slow.

Debugger stops not only when the process terminates with an exception but on each exception thrown (even though it was caught and didn't lead to the process termination).

Clear the On raise checkbox in the Breakpoints dialog (Run | View Breakpoints).

The following error message appears on your first attempt to attach to a local process: ptrace: Operation not permitted.

It a known issue for Ubuntu.

Ensure that the kernel.yama.ptrace_scope kernel parameter is set to 0. You can temporary change its value with the command sudo sysctl kernel.yama.ptrace_scope=0 or set it permanently by adding the kernel.yama.ptrace_scope = 0 line to the /etc/sysctl.d/10-ptrace.conf file.

Cython Speedups

The following error message is shown:

Python.h: no such file or directory.

You lack header files and static libraries for Python.

Use your package manager to install the python-dev package system-wide.

On Linux and macOS, you can run the following command:

sudo apt-get install python-dev

To install the package for specific Python version, use python-dev<version>. For example:

sudo apt-get install python3.11-dev

The following error message is shown:

Command 'gcc' failed with exit status 1.

You lack a C compiler.

Install a C compiler in order to build Cython extensions for the debugger. For more information, refer to the Cython documentation.

You have already clicked the Install link in the Cython speedup extensions notification but PyCharm repeatedly prompts to install it.

You do not have permissions to write in the directories used by PyCharm.

Check and modify your permissions.

Packaging

Package installation fails.

pip is not available for a particular Python interpreter, or any of the installation requirements is not met.

  • If pip is not available, install it for the required Python interpreter (see the corresponding troubleshooting tip)

  • Consult product documentation for a specific package to ensure that it can be installed in your operating system and for the target Python interpreter. Also, check if any additional system requirements should be met.

Docker (refer to Docker troubleshooting)

File Watchers You might notice the following messages in the Preferences/Settings | Tools | File Watchers window.

Unknown Scope error

The File Watcher uses a scope that is not defined in this project.

Double-click the watcher and select an available scope or create a new one.

Not found error

The project uses a global File Watcher that was removed.

Delete the watcher from the list using the Remove button Remove or edit it to create a new global watcher with the same name.

Deployment

Error message when using SSH configurations:

Connection to <server> failed: SSH: invalid privatekey: [<key>. SSH: invalid privatekey: <key>

The RFC 4716 format for OpenSSH keys is not supported by PyCharm.

  • Add the private keys to ssh-agent using the ssh-add command (see more details at ssh.com)

  • Repeat the configuration step in the Add Python interpreter dialog.

  • Add the private keys to ssh-agent using the ssh-add command (see more details at ssh.com)

  • In the Settings dialog (Ctrl+Alt+S) , select Build, Execution, Deployment | Deployment, then select your SFTP deployment configuration.

    Choose OpenSSH Config and authentication agent in the Authentication list.

The Profile command is not available in the Run menu.

  • This functionality is available only in the Professional edition of PyCharm.

  • The Diagrams plugin that is bundled with PyCharm Professional has been disabled.

Check the edition of PyCharm and enable the Diagrams plugin in the plugin settings.

In some cases, you might need to perform diagnostic steps to identify whether the problem occurs in PyCharm or in your working environment. Below is the list of the useful tips and tricks.

Troubleshooting case

Diagnostic action

You are experiencing different behavior of your application when running it in PyCharm and in the Terminal window.

Run your script with the python version specified in the PyCharm project settings:

  1. In PyCharm, open the Settings dialog Ctrl+Alt+S, navigate to Project < project name> | Python Interpreter.

  2. Click Interpreter nearby the Python Interpreter field and select Show All.... The interpreter you use in your project will be selected in the list of the available interpreters.

  3. Click Edit interpreter and copy the path from the Interpreter path field.

  4. Now, run your script in the Terminal window using the copied path

    <copied python interpreter path> <path to the python script>\my_script.py. For example, C:\Python27\python.exe C:\Samples\my_script.py

  1. In PyCharm, open the Preferences dialog Ctrl+Alt+S, navigate to Project < project name> | Python Interpreter.

  2. Click Interpreter next to the Python Interpreter field and select Show All.... The interpreter you use in your project will be selected in the list of the available interpreters.

  3. Click Edit interpreter and copy the path from the Interpreter path field.

  4. Now, run your script in the Terminal window using the copied path

    <copied python interpreter path> <path to the python script>/my_script.py. For example, /Users/jetbrains/bin/python3 /Users/jetbrains/Samples/my_script.py

If the behavior of your application still differs, contact the support service pycharm-support@jetbrains.com

The required package is not installed for a particular Python interpreter. A version of the package installed for a particular Python interpreter is outdated.

Run the following commands to install the required package:

<path to the python executable>\python.exe -mpip install '<package>'

For example, C:\Python27\python.exe -mpip install 'Flask'

Once executed, these commands install the latest versions of the specified packages.

To install a particular version of the package, use the following expressions:

  • '<package>==<package_version>' – installs a specific version of the package

  • '<package>>=<package_version>' – installs a greater than the specified or later version of the package

  • '<package>~=<package_version>' – installs a version that is compatible with the specified version of the package

For example, the following command installs Flask compatible with the version 1.0.2: C:\Python27\python.exe -mpip install 'Flask~=1.0.2'

<path to the python executable/python -mpip install '<package>'

For example, /Users/jetbrains/anaconda3/bin/python -mpip install 'Flask'

Once executed, these commands install the latest versions of the specified packages.

To install a particular version of the package, use the following expressions:

  • '<package>==<package_version>' – installs a specific version of the package

  • '<package>>=<package_version>' – installs a greater than the specified or later version of the package

  • '<package>~=<package_version>' – installs a version that is compatible with the specified version of the package

For example, the following command installs Flask compatible with the version 1.0.2: /Users/jetbrains/anaconda3/bin/python -mpip install 'Flask~=1.0.2'

When trying to install a package, you discover that pip is not available for a particular Python interpreter.

Try to bootstrap pip from the standard library:

<path to the python executable>\python.exe -m ensurepip --default-pip

For example, C:\Python27\python.exe -m ensurepip --default-pip

<path to the python executable/python -m ensurepip --default-pip

For example, /Users/jetbrains/anaconda3/bin/python -m ensurepip --default-pip

For more information about pip installation, refer to packaging.python.org

Last modified: 11 February 2024