PyCharm 2018.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

Code Editing

PyCharm Editor restricts code editing.

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

In the Settings/Preferences dialog (Ctrl+Alt+S), navigate to Plugins and disable the IdeaVim plugin as described in Managing Plugins.

Python code is not highlighted in the Editor.

The PY files are associated with the text file format.

In the Settings/Preferences dialog (Ctrl+Alt+S), navigate to Editor | File Types, select Text from the Recognized File Type list, select *.py from the Registered 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 suggestions list is a plain text file.

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

Debugging

Python Debugger hangs when debugging Gevent code.

Gevent compatibility mode is not enabled.

In the Settings/Preferences 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/Preferences 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).

Cython Speedups

The following error message is shown:

Python.h: no such file or directory

You lack header files and static libraries for Python dev.

Use your package manager to install header files and static libraries for Python dev system-wide.

For example, you can use the following commands:

  • for Python 2.x:

    sudo apt-get install python-dev

  • for Python 3.5:

    sudo apt-get install python3-dev

  • for Python 3.6:

    sudo apt-get install python3.6-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

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

Unable to connect to Docker

Docker is not running, or your Docker connection settings are incorrect.

If you are using Docker for Windows, enable the Expose daemon on tcp://localhost:2375 without TLS option in the General section of your Docker settings.

If you are using Docker Toolbox, make sure that Docker Machine is running and its executable is specified correctly in the Settings / Preferences dialog (Ctrl+Alt+S) under Build, Execution, Deployment | Docker | Tools.

When you try to pull an image, the following message is displayed:

Failed to parse dockerCfgFile: <your_home_dir>/.docker/config.json, caused by: ... {"credsStore":"wincred"}

Invalid Auth config file when using credsStore: http://github.com/docker-java/docker-java/issues/806

Go to <your_home_dir>/.docker directory and delete the config.json file.

Unable to use Docker Compose

Docker Compose executable is specified incorrectly.

Specify Docker Compose executable in the Settings / Preferences dialog (Ctrl+Alt+S) under Build, Execution, Deployment | Docker | Tools

Unable to use port bindings

Container ports are not exposed.

Use the EXPOSE command in your Dockerfile

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

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 Tips

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> | Project Interpreter.

  2. Click Interpreter nearby the Project 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> | Project Interpreter.

  2. Click Interpreter next to the Project 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: 7 December 2018