PyCharm is the most popular IDE used for Python scripting language.
Features of PyCharm
- Code completion and inspection
- Advanced debugging
- Support for web programming and frameworks such as Django and Flask
In order to work with your Python code in PyCharm, we need to configure at least one interpreter PyCharm. You can configure more than one interpreter in PyCharm and use the required interpreter as your need.
When you configure a Python interpreter, you need to specify the path to the Python executable in your system. The user can create several Python interpreters based on the same Python executable. This is helpful when you need to create different virtual environments for developing different types of applications. For example, you can create one virtual environment based on Python 3.6 to develop Django applications and another virtual environment based on the same Python 3.6 to work with scientific libraries.
To configure a new interpreter in PyCharm, follow the steps given below:
- Open the project Settings/Preferences ( Ctrl+Alt+S ).
- In the Settings/Preferences dialog, select Project <project name> | Python Interpreter. Click the icon and select Add.
- Choose the interpreter type to add and perform the specific settings:[Note that SSH, WSL, Vagrant, Docker, and Docker Compose are available only for the commercial version of PyCharm. WSL is Windows specific.]
- In the left-hand pane of the Add Python Interpreter dialog, select Virtualenv Environment. The following actions depend on whether the virtual environment existed before.If New environment is selected:
- Specify the location of the new virtual environment in the text field, or click and find location in your file system. Note that the directory where the new virtual environment should be located, must be empty!
- Choose the base interpreter from the list, or click and find a Python executable in the your file system.If PyCharm detects no Python on your machine, it provides two options: to download the latest Python versions from python.org or to specify a path to the Python executable (in case of non-standard installation).
- Select the Inherit global site-packages checkbox if you want to inherit your global site-packages directory. This checkbox corresponds to the
--system-site-packagesoption of the virtualenv tool.
- Select the Make available to all projects checkbox, if needed.If Existing environment is selected:
- Expand the Interpreter list and select any of the existing interpreters. Alternatively, click and specify a path to the Python executable in your file system, for example, C:\Python36\python.exe.
- Select the checkbox Make available to all projects, if needed.
- Click OK to complete the task.