Downloading >=Python 3.10 for VS Code - python

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.

Related

Unable to change Python 2.7 to Python 3.8 on Sublime and VS code

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

Windows Python 3.9, pip, vscode not working correctly tried every tutorial

I've gotten this to work relatively easy on my Mac I with django but for some reason Windows has been a heartache.
the problem is that in the console I can only get py to start executing python.
python and python3 do not work whatsoever
and also I can't get pip to install either because the py command won't execute it but python and python3 just open the windows store.
I've installed python to the path with the installer and I made the location of the file C:\Python\Python39
changed the hierarchy in the PATH in user variables and system variables to where python is at the top in both.
I've edited the vscode settings
I've also turned off the App execution aliases. That did nothing.
I'm at a complete loss so if any one has any advice I'd be so appreciative.
This tutorial helped me make pip working when I started programing
https://youtu.be/28eLP22SMTA

Arrow up / previous command in VSCode Python Interactive not working

I'm working with VSCode on an Ubuntu 18.04 machine. Everything is fine except that I can't get back to the previous command in Python Interactive Window via Arrow Up. It works in the integrated terminal though, integrated shell is /bin/bash.
I have no idea where this is coming from. I changed "keyboard.dispatch" to "keyCode", but that's not the problem. I also tried different versions of the python-extension.
Do you have any idea?
Thanks!
Not sure if this is helpful for you as an Ubuntu user, but I came across the same problem in Windows this week. In my case, the issue cropped up after I installed the Python extension in VS Code (or at least I didn't notice the issue before this). The combination of using the Python extension, Git Bash for terminal, and python virtual environment killed the up arrow feature for me. Using python outside a virtual environment works fine. My solution was to use Command Prompt as the terminal when I wanted to use a virtual environment interactively.
In my situation, although I delete all the shortcuts of UpArrow, I still can get the previous command through UpArrow in Python interactive. This means there's no way to configure this shortcut, it was built in the plugin which built in Python extension.
So it's some problem with your Python extension, but you said you have tried to install a different version of Python extension but still not work. Make sure you have deleted it completely -> delete the extension folder manually(it's under C:\Users[UserName].vscode\extensions\ms-python.python-xxx).

How to tell VScode, on my Mac running high Sierra, which version of python to use

I use VScode to write and run python. I use it with a Jupyter extension. I have 2 virtual environments created using Anaconda. One py27, for python 2.7.13 and the other, py36, for Python 3.6.5.
I have a simple code which I edited to only run in python2. When I run VScode, the virtual environment I run it in does not seem to matter. VScode seems to run but I can't figure out how to make it use py36 (python 3.6.5) or py27 (python 2.7.13).
By using different commands in the command palette, or double-clicking on phrases in the bottom border of VScode I can eventually get it to run which version I want. But I have not found a reproducible method.
I have tried about 100 times with no luck. I thought I found a method that would repeat but I tried it again and it didn't work.
I know this question is very vague but it would take pages to explain what I've tried. I have about 5 or 6 settings which I've tried a plethora of combinations. One of the commands I tried is to select a python interpreter. I have several options but none seem to have an effect. Also, in the bottom border of the VScode window, there is the name of a specific python interpreter. You can click on this to select a different python interpreter. As far as I can tell this doesn't do anything. Actually, it's a hindrance because a user may think they are actually using that interpreter.
I've tried both py27 and p36 but I get no difference. If I can get visual studio code to start out in py27, I can make it change to py36 and back to py27. But how to make it start in py27 seems random. My virtual environments are in my home directory, /User/myname/py27 for example along with the VScode app.
The documentation at https://code.visualstudio.com/docs/python/environments explains how to select your virtual environment. Without knowing where you installed the virtual environments the best I can tell you is you can manually specify what interpreter to use with the python.pythonPath setting or if you have both virtual environments in a directory outside of your workspace folder you can specify the common folder with the python.venvPath setting.

How do I set up Python 3 with IntelliJ IDEA on OSX?

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.

Categories

Resources