Git-bash using wrong version of Python - python

I am new to git-bash and am currently trying to make the Git Bash use the correct version of Python. I just installed version 3.8.1, but Git is using the 3.7.3 version.
When I run the which python command, it displays the directory of the 3.7.3 Python as expected. How can I switch it so that it is using the updated version?
Let's say, for example, the location of the Python I want to use is /c/Users/tom/Python3.8.1/python.
I am tried to solve this by searching online and I came across a post that suggested I use the following command:
PATH="path to executable python":PATH
But that did not seem to work as after I ran that, it would no longer let me use the which python command

Related

Downloading >=Python 3.10 for VS Code

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.

Terminal's python version and Eclipse's python version mismatch

My MacBook came preinstalled with Python 2.7.16, and I downloaded Python 3.8.5. To my understanding, the operating system needs Python 2.x so I did not uninstall it.
Eclipse (using Pydev) is the IDE I'm using.
I set up two interpreters, one for python and the other python3.
I set up one project for each interpreter to make sure I set them up correctly.
The script is:
import sys
print(sys.version)
When I run it with the python interpreter, I correctly get version 2.7.16.
When I run it with the python3 interpreter, I instead get 3.8.2.
Running python -V yields ``Python 2.7.16. Running python3 -VyieldsPython 3.8.5```.
Why does the interpreter return one version and the terminal another?
I'm at a loss for how to troubleshoot or fix this, or if it is a non-issue.
To clarify, you get the 2.7.16 and 3.8.2 versions when running your program from within Eclipse. The python -V is clearly from the command line. The interpretation is that your Eclipse environment came with its own python interpreter which happened to be 3.8.2. Have you tried running your script from the command line with python3 path/to/your/script.py? This probably gives 3.8.5. I don't see a real problem here in most cases you do not care whether you have python 3.8.2 or 3.8.5.
The "biggest" issue is a cosmetic one that you have two python3 installations which is a bit of a waste. When using additional libraries, you may find that you have to install them in your Eclipse environment and in your command line if you want to use your scripts in both environments which would be a bit tedious. If this does turn out to be a problem, check in Eclipse whether there is any way to change your python3 configuration to use the interpreter used by the command line (sorry cannot be more specific, it's a long time that I used Eclipse).

Can I temporarily set python to default to an earlier version?

Can I temporarily set python to default to an earlier version?
I have been trying to run a few scripts I downloaded from GitHub written in python 2.7 and my default python version is 3.7.6. I know that I can run one script with 2.7 using: python2 FoEC.py -i ./testdata/ for instance. However, this script calls other .py scripts also written in 2.7 that I believe are running using 3.7.6 (the keep getting syntax errors which don't appear when run in 2.7). Is there a way to ensure that all scripts are run using python 2.7?
I hope that this makes sense.
Thanks,

Running or compiling a Python script on Windows

I want to modify this Python script on Windows 7.
https://github.com/Jeremy1980/LDBoxer
The original author seems to have compiled the program into a Windows executable. Is it possible to run the script without compiling it? I tried the following at the command prompt:
python LDBoxer.py
But Windows says it does not recognize 'python'. What do I need to install and what is the correct command line syntax? According to the docs, this is the correct way to run the executable:
LDBoxer_2017a.exe ldraw_library_location ldraw_model_location_for_conversion
Thanks.
You need to make sure you have python installed, then make sure you are running the correct python compiling command. Sometimes when installing python 2 you need to run the command python2 or python27.
You can install python here. It looks like they wrote it with python 2.x so I would recommend installing python version 2.7 unless you want to manually convert it to python 3.x.
You should be able to run the .exe just by double clicking, or right click then run.

VS Code not detecting Python3 interpreter on MacOS

I just upgrade python3 to 3.6 (using homebrew) and now VS Code doesn't seem to be aware of it. When I try to select my Python interpreter I see 2.7.9 and 2.7.10 (in /usr/bin and /usr/local/bin respectively) but I do not see 3.6.3 (/usr/local/bin/python3).
It's certainly in my path, and I'm aware that I can update settings.json manually, but I use both Python 2 and 3 for various projects and making them available via the interpreter switcher would be incredibly useful. Any ideas why Code isn't autodetecting python3? Or is there a way for me to force-add it to the list?
Figured it out. Something I clearly installed had modified by .bash_profile to include the following:
# Setting PATH for Python 2.7
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH
I commented that out, restarted Code, and now I can see all my Python interpreters listed (including 3.6.3).
In VS Code, you're able to easily set the interpreter you'd like to use for Python. Follow this official guide.
From the site:
To select a specific interpreter, select the Python: Select Interpreter command from the Command Palette (⇧⌘P).

Categories

Resources