I'm highly confused about this. Python3 is installed per default on the MacBook.
which python3 will output /Library/Frameworks/Python.framework/Versions/3.6/bin/python3
Great, so that's my SDK to put into IntelliJ IDEA, one should think.
I have the Python plugin for IDEA. However, I can't run Python files. So I try to change the configuration and set it to the above PATH for the Python interpreter.
However, still nothing. Trying to run the Python file inside IDEA will prompt a new configuration?
I can run the script just file doing python3 script.py in the terminal? I know the path for the Python3 library, yet, IDEA doesn't recognise it at all and doesn't save the configuration.
What am I doing wrong in this process? This should be fairly easy to set up but turns out it isn't :)
I even tried to create a Python 3.6.2 virtual environment with the IDEA internal tool - same thing? It doesn't allow me to run the Python3 script from inside IDEA.
Should I use python from usr/bin/python? If I cd there, I can see Python3. But inside IDEA, i only have access to Python2..
After installing Python 3.8.1 via pyenv which I now recommend over using Homebrew (see https://github.com/pyenv/pyenv), I did the following to add this version to IntelliJ IDEA.
Close all open projects. This will display the Welcome to IntelliJ IDEA window listing recent projects along the left.
Click on Configure -> Structure for New Projects
Click on SDKs under Platform Settings along the left
Click on the + sign above the SDK list and select Python SDK
From the Add Python Interpreter window, select System Interpreter
Click on the ... button to the right of the Interpreter drop down and browse to $HOME/.pyenv/versions/3.8.1/bin/python. Replace 3.8.1 with the desired Python version if you want to configure another version.
Updated for IntelliJ IDEA 2019.3.3
Try this in menu of IDEA: File -> Settings -> Project: Name of project -> Project Interpreter and from above in the window you can choice interpreter version or virtualenv.
Related
I am a complete beginner at Python and am going through the CS50P tutorial. The tutorial just went through match commands, and as I tried to run a program including match on VS Code an error message appeared telling me that I do not have a version of Python that supports match. How can I get Python 3.10 on VS?
I have tried going through the VS Code gui but haven't had any luck. Because of my extreme inexperience I am just assuming that I am looking in the wrong places.
Follow this steps(hope will help you):
Download python from the official website python website and chose the version you want
Make sure you add python to the virtual environment by clicking (add python to environment variable) like this image
setup python.
After that go to VSCode and install the python extension.
Open the python file now we can see the python version button next to the python button in VSCode lower bar just click it and a will popup window to choose Interpreter now click (Enter interpreter path) then (Find).
Now go to the path where python is installed and chose (python.exe) to find the python path just type (where python) in cmd if you're using Windows.
You should look into Conda. It makes working with different versions of python easy.
With conda installed this task would be as easy as:
conda create -n py310 python=3.10
Then just tell VS to use py310 environment.
I have been trying to change my python interpreter on sublime text and VS code and no matter what I do, both of them refuse to change. It always picks the default Python 2.7 version.
On sublime, I tried to create a new build tool, added the path to Python3 but nothing is working.
And on, VS code, even if I select Python3 from the drop-down menu, it doesn't change anything.
I changed the system's default python interpreter from 2.7 to 3.9 and set the path on bash profile. It fixed the issue for me.
I don't know about Sublime, but for VS Code, there looks to be quite a few things to verify:
Check your User Settings on whether you've set up a default interpreter for your applications
Are you using Window 10 WSL? Then you might want to check out issue 3227 for vscode-remote-release where the comment was:
So I was having this same exact issue until I read this article on a wsl tutorial. In there it says we should have "Remote - WSL" extension installed (already did). In the bottom left corner "Remote - WSL" installs a status button that has the "greater than" and "less than" symbols displayed. If you click that button and tell VSCode to open up in the remote WSL distro environment it fixed my issue where vscode was unable to find an interpreter for python.
For Sublime, you need to hit ⌘B with your script pane focused in order to use your new python3.sublime-build build system.
It looks like you are running your script within Terminus, which is fine, but you need to use the python3 command when running it from the command line, even if that command line is within Sublime.
Please check out my answer here on how to make a Python build system that accepts user input, as the Sublime "console" doesn't allow you to interact with your program. Since you already have Terminus installed, I'd recommend going down to the bottom of the answer and using the Terminus build system. That way, you won't have to deal with Terminal windows opening every time you run a build.
The terminal window uses your PATH, not the IDE settings, so manually typing out python --version isn't testing anything except the PATH variable
In order for the terminal to use the "correct" python binary you've specified, it would need to give the absolute path to it, which I believe using Command+B (using the build options) in Sublime would do. Similarly, you can use the Run/Debug Configurations in VSCode.
Or you can modify your ~/.zshrc to fix your PATH, for example installing pyenv to change the entire system Python version, or the one for the current folder
I am using Python 3.7 on windows. I installed Pycharm and successfully wrote a script which I am now trying to schedule using Windows Task Scheduler, which comes with its on set of complications. One thing I have noticed about Pycharm is I think it has created a separate file directory to store any packages I add to a script (maybe in something called "venv"? Instead of using the User/Python37/Scripts file.
This means when I try to run my script in the command prompt, python.exe looks for packages and cannot find them. Also if I go into my Pycharm project folder is see another instance of a Python Application file different than the Python Application stored in User/Python37. I think this also creates problems but I am not 100% sure.
I am hoping someone has seen this issue and can help me align where Pycharm stores packages. Any help would be greatly appreciated.
You can also simply add your script/package into your python path.
For that follow this awser : How to add to the PYTHONPATH in Windows, so it finds my modules/packages?
PyCharm creates a virtual environment (venv) where you can keep the python version and the libraries used in a specific project.
You can add libraries to the specific environment through the Pycharm GUI:
File > Settings > Project: Patterns > Project Interpreter > Install (green +)
Find your package and click Install Package in your venv.
You can see all the installed packages and their version in the path:
File > Settings > Project: Patterns > Project Interpreter
You can also use pip install, if you want to go through CLI, but be sure to use the virtual environment's pip (located in project_folder/venv/Scripts).
If for some reason you want to use the python version outside the virtual environment, go to the following path in PyCharm:
File > Settings > Project: Patterns > Project Interpreter
In the Project interpeter dropdown menu, you should find other python's location; choose the one you prefear. If you don't see your standard python version (usually in C:\python\python.exe, or something similar), you can add it by clicking on the settings menu, and specify the path to the desired python version in Base interpreter:.
In this window, you can find other settings to configure the interpreter as you want.
I have PyCharm 1.5.4 and have used the "Open Directory" option to open the contents of a folder in the IDE.
I have Python version 3.2 selected (it shows up under the "External Libraries" node).
How can I select another version of Python (that I already have installed on my machine) so that PyCharm uses that version instead?
File -> Settings
Preferences->Project Interpreter->Python Interpreters
If it's not listed add it.
I think you are saying that you have python2 and python3 installed and have added a reference to each version under Pycharm > Settings > Project Interpreter
What I think you are asking is how do you have some projects run with Python 2 and some projects running with Python 3.
If so, you can look under Run > Edit Configurations
PyCharm 2019.1+
There is a new feature called Interpreter in status bar (scroll down a little bit). This makes switching between python interpreters and seeing which version you’re using easier.
Enable status bar
In case you cannot see the status bar, you can easily activate it by running the Find Action command (Ctrl+Shift+A or ⌘+ ⇧+A on mac). Then type status bar and choose View: Status Bar to see it.
This can also happen in Intellij Ultimate, which has PyCharm integrated. The issue is as diagnosed above, you have the wrong interpreter selected.
The exact method to fix this for any given project is to go to Project Settings...Project and adjust the Project SDK. You can add a New Project SDK if you don't have Python 3 added by navigating to the python3 binary. This will fix the errors listed above. A shortcut to Project Settings is the blue checkerboard-type icon.
You can also add Python 3 as the default interpreter for Python projects. On OSX this is in File..Other Settings...Default Project Structure. There you can set the Project SDK which will now apply on each new project. It can be different on other platforms, but still similar.
Go to:
Files -> Settings -> Project -> *"Your Project Name"* -> Project Interpreter
There you can see which external libraries you have installed for python2 and which for python3.
Select the required python version according to your requirements.
Quick Answer:
File --> Setting
In left side in project section --> Project interpreter
Select desired Project interpreter
Apply + OK
[NOTE]:
Tested on Pycharm 2018 and 2017.
I have a working Python project on my PC, which I am running from Pycharm.
It uses Pyroot (an interface to Root C++ library), whose C++ lib path I have added in Project Settings/Python Interpreter/Paths in Pycharm. It also needs to use the 2.7 Python interpreter, instead of 3., which is a default python in my terminal.
I want to run this project remotely on another desktop, so I need to be able to run it from terminal specifying the path to Root and the interpreter version.
Is there a way to easily extract from Pycharm the exact run command it is using when I'm running the code via run button?
Alternatively, if that's impossible, how should I specify the path to Root and the interpreter version when running from terminal?
I guess to best way is to create a virtualenv either in the terminal or in pycharm including the corrext python version 2.7 and install pyroot via pip into this virtualenv. Then you can simply ssh in the remote host, activate the venv and start your project from the terminal. Or you ssh into it with X-forwarding and start Pycharm itself from your client.
If you select the correct project and go to File > Settings, under the Project Settings you can see the Project Interpreter which tells you which interpreter is being used.
Hope this is what you are looking for.