Python интерпретатор для pycharm

How can I add interpreter to PyCharm?

When I try to run code in editor,it says that there is no available interpreters.Please,help.How can I solve the problem?

This now is in all new projects, so it offers the virtualenv interpreter and locates installed Python(windows) as base interpreter

4 Answers 4

Just read the PyCharm’s Docs.

  1. Go to Settings .
  2. Go to the section Project Interpreter .
  3. Click on the plus (+) button and select the Local option.
  4. Search for the interpreter, in Linux it is used to be in /usr/bin/python or /usr/bin/pythonX.Y where X and Y are the version. In Windows, it is used to be in C:\python .
  5. Last step save the settings and you have configured the interpreter.

PD: If you are on Linux python is installed and if you are using Windows, you can download from here: https://www.python.org/downloads/windows/

I think it’s better to run this command

$ sudo apt-get install python3-distutils

This page Configuring Python Interpreter tells all the information you need.

To configure Python virtual environment, follow these steps:

enter image description here

  1. In the Settings/Preferences dialog (⌘,), click Project Interpreter.
  2. Click gear icon and choose Add .
  3. In the left-hand pane of this dialog, click the Virtual Environment node.
  4. Click OK to apply changes and close the dialog box.

Источник

Configure a system interpreter

To work with your Python code in PyCharm, you need to configure at least one interpreter. A system interpreter is the one that comes with your Python installation. You can use it solely for all Python scripts or take it as a base interpreter for Python virtual environments.

Configure a system interpreter

  1. Ensure that you have downloaded and installed Python on your computer. Installing Python on Windows from Microsoft Store If you are on Windows, you can download Python from the Microsoft Store and install it as a Python interpreter. Once the Python application is downloaded from the Microsoft Store, it becomes available in the list of the Python executables. Note that interpreters added from the Microsoft Store installations come with some limitations. Because of restrictions on Microsoft Store apps, Python scripts may not have full write access to shared locations such as TEMP and the registry.
  2. Do one of the following:
    • Click the Python Interpreter selector and choose Add New Interpreter .
    • Press Control+Alt+S to open Settings and go to Project: | Python Interpreter . Click the Add Interpreter link next to the list of the available interpreters.
    • Click the Python Interpreter selector and choose Interpreter Settings . Click the Add Interpreter link next to the list of the available interpreters.
  3. Select Add Local Interpreter .
  4. In the left-hand pane of the Add Python Interpreter dialog, select System Interpreter . Adding a system interpreter
  5. In the Interpreter drop-down, select one of the Python interpreters that have been installed in your system, or click and in the Select Python Interpreter dialog that opens, choose the desired Python executable. Selecting the Python executableYou will need admin privileges to install, remove, and upgrade packages for the system interpreter. When attempting to install an interpreter package through an intention action, you might receive the following error message: System Interpreter warning messageAs prompted, consider using a virtual environment for your project.
  6. Click OK to complete the task.
Читайте также:  Php http post request body

For any of the configured Python interpreters (but Docker-based), you can:

Источник

Configuring a Local Python Interpreter

How to set up a local Python interpreter for your project.

In the previous step, we customized the IDE. In this step we’re going to learn how to set up a Python interpreter using PyCharm.

New Interpreter

When we’re talking about local interpreters, PyCharm lets us configure them in two main ways:

  • You can select and use your system interpreter
  • Or you can create a virtual environment using virtualenv, Pipenv, Conda, or Poetry

You just need to have a Python installation already setup on your local machine. PyCharm lets you select your interpreter at three different points.

Firstly, you can select the interpreter when you create a new project. We already covered how to create a new project, but we skimmed the Python interpreter configuration.

When you create a new project, you need to choose between creating a new interpreter or selecting a previously configured interpreter. Let’s create a new one.

The first thing you will need to define is what kind of Python packaging manager you want to use. PyCharm comes with support for virtualenv, Pipenv, Conda and Poetry out of the box. Let’s use virtualenv. PyCharm will automatically identify the location where the venv folder will be created.

virtualenv_interpreter

This new interpreter will be based on an existing one. In my case, this is Python 3.10. You can also choose another base interpreter from the list, or click the three dots to find another Python executable in your file system.

Secondly You can also create a virtualenv using Pipenv. Getting Pipenv installed on your system is an extra step. Once setup and visible to PyCharm, you can select it from the drop-down.

Читайте также:  Check if java plugin is installed

Finally, you can also create a virtual environment using Conda. Make sure that Anaconda or Miniconda is downloaded and installed on your computer then pick Conda from the dropdown, check if the location is correct. Select the Python version, then ensure that the Conda executable path is correct. The environment will be automatically created within your Anaconda installation.

We just saw making a new interpreter and the various Python standards for doing so.

Existing Interpreter

That’s how you create a new virtual environment in PyCharm when setting up a new project, but we can also select an existing Python project, that we haven’t yet opened as a PyCharm project.

From the New Project screen, click Previously configured interpreter. If you already have interpreters previously configured you can just pick the one you would like to use from this dropdown. If you see a no interpreter message here you can click the three dots.

Existing Interpreter

Then, select it from the different options, including virtualenv environments, conda environments, pipenv interpreters, or even your system interpreter.

Clone project

The second place you can configure your interpreter is when you clone a project from VCS. In the PyCharm Getting Started screen, you can click Get from VCS button.

We can paste the repository URL in and accept the generated choice for the directory to clone into, and click Clone.

Clone project

PyCharm opens a new project in that directory and starts cloning the repository. Once the clone has finished, PyCharm makes a project interpreter, based on your default Python, and starts installing the packages in your requirements file.

Читайте также:  Background Color: body gbcolor

Open project

We have a cloned project and PyCharm has a “project interpreter” for it, but what if you want to change the interpreter used by a project? You can see which interpreter the project is using in the bottom-right of the screen. There are two ways to change this.

You can click the interpreter name in the Status Bar which opens a list of available interpreters. It will also give you the opportunity to either open interpreter settings or add a new interpreter.

Alternatively, you can find the same settings in your Preferences/Settings (⌘, | Ctrl+Alt+S) and then search for project interpreter. If you click the gear icon to the right of the drop-down, PyCharm will give you options for managing all the project interpreters that PyCharm knows about.

Conclusion

That’s it! We just went through configuring local Python interpreters in PyCharm.

In the next step, we’ll see how to configure remote interpreters in PyCharm.

Video

You can also check out the video for this step from our Getting Started series on YouTube:

Источник

Оцените статью