I'm new to VS Code/Python, and I'm trying to get VSCode to run a specific version of Python (seems I have multiple versions installed).
I tried the following code:
import sys
print(sys.version)
When I run the file, some reason, it shows:
3.5.2 |Anaconda 4.2.0 (32-bit)| (default, Jul 5 2016, 11:45:57) [MSC v.1900 32 bit (Intel)]
I've tried the following: At the very bottom of VSCode, I clicked on the Python version, then clicked on "Python 3.7.3 64-bit", but when I reran the code, it still shows "3.5.2 |Anaconda..."
I also tried checking the settings, and it's showing:
Python: Python Path
C:\Users\[MY_USE_NAME]\AppData\Local\Programs\Python\Python37-32\python.exe
I also tried just typing "python" in the command like, and it still says "Python 3.5.2".
Any idea what I'm doing wrong? I'm very new to VS Code, so hopefully it's something simple.
From the Command Palette (Ctrl+Shift+P), select the Python: Start REPL command to open a REPL terminal for the currently selected Python interpreter. In the REPL, you can then enter and run lines of code one at a time.
Install Python and the Python extension# Once you have a version of Python installed, activate it using the Python: Select Interpreter command. If VS Code doesn't automatically locate the interpreter you're looking for, refer to Environments - Manually specify an interpreter.
For choosing interpreter, press ctrl + p
and then type >Python: Select Interpreter
(don't forget the >
character! if it doesn't show up, make sure you have installed python extension on your vs code) and select one of the options. It will show you available interpreters (virtual environments + the global environment) to choose.
If you want to change version of python you are using, you must first create a virtual environment with desired version of python and then choose it as your interpreter. (I recommend to create it in .venv
directory in the root directory of your project)
This answer will help you with that.
Open command pallete with F1
(on Windows) and type Python: Select Interpreter
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With