Python upgrade issue from 3.9 to 3.10 on Windows - python

I had a Python 3.9 installed on my Windows 10 machine and it had a lot of issues, so I had to upgrade it to Python 3.10
I uninstalled Python 3.9 from my machine, and installed 3.10, and added it to PATH.
I also had a Python 3.7 instance as well.
Now after installing Python 3.10, pip and virtualenv are not working anymore, when I try to install virtualenv using pip, I get this error:
Fatal error in launcher: Unable to create process using '"c:\users\wwwwww\appdata\local\programs\python\python37\python.exe" "C:\Users\wwwww\AppData\Local\Programs\Python\Python37\Scripts\pip.exe" install virtualenv': File not found
Even after uninstalling Python 3.9, I can still see 3.7 and 3.9 on my machine:
When I try python on my Visual Code terminal, I get the shell and everything works fine:
But when I try to run it on Git Bash, I get nothing, and the terminal crashes:
I want to reset everything and remove all python and pip so I can start from scratch and continue my work because I'm blocked right now.

The problem is with Windows 10 and their decision to automatically enable Python as an execution alias, and thus impacting the command line behavior.
To solve this issue, simply go to Windows Parameters -> Apps and Features, and search: Manage Apps Execution Aliases.
Uncheck every Python mention in the list:
And now the problem is solved:

Related

Installing Python on macOS

I am new in macOS, and I have a little problem with installing python. I have downloaded from python webpage current version 3.9, and installed it. Now if I open command line, and write command
python3 -V
get result
Python 3.8.2
If I run
sudo python3 -V
I get
Python 3.9.7
How can I change it, I would like to have same version even tough I run it without sudo.
An easy way to keep everything consistent is to use something called a Virtual Environment. Here is a ref:
https://sourabhbajaj.com/mac-setup/Python/virtualenv.html
A few tips:
Create the venv under a folder that will work as the top folder of your new 'Workspace'.
You will need to activate your venv with this command:
source venv/bin/activate
I promise it is much easier than it sounds, and it works great.
If python 3.8.2 still comes up wherever and you don't need it then that means it's obviously still in your system so locate the folder and application somewhere and just deleting it by moving to bin should do the trick, make sure you're deleting the right version of python, do not delete Version 2.7 because macOS needs it to run things
Try pyenv
Managing multiple python version is not easy.
With pyenv, you can install a python version as simple as pyenv install 3.3.6. It's also quite easy to manage multiple python version and to switch version for different terminals.

PIP version VSCode

I am having troubles trying to understand why VSCode uses a different pip version.
I have two python versions installed in Windows, python38 and python39, if I open the win 10 terminal I got pip version 20.2.4 when running pip3 --version, but if i run the same command inside the VSCode terminal i got pip 20.2.2 from c:\python38\lib\site-packages\pip (python 3.8).
Both terminals are running PowerShell 7.0.3 on the same profile.
Also removing python38 from the global PATH variable gives command not found error only in vscode, in windows terminal keeps working as i described before.
Could not fix this so I deleted all temporary and profile data of vscode and can now run pip from within its terminal.
Try changing your interpreter: ctrl+shift+p->select python interpreter and choose the one you want because pip is part of the python environment, and therefore the version of pip you are using is tied to the active python interpreter (cc #DragonBobZ)
It's all about the Process PATH. Check $Env:PATH in both. Starting from the left, the first folder with pip3.exe is used. You have probably selected a python interpreter for VS Code, which then adds it in the PATH.
You can also check the location of the used pip3.exe with Get-Command pip3. (might be helpful in debugging)
It appears something got fixed after deleting all profile and settings data from visual studio code, it runs pip now form the terminal inside vscode.

Python path configuration for pyinstaller

I am having issues with getting pyinstaller version 3.6 to work to make my application executable. The crux of my problem is that pyinstaller is not compatible with python 3.8, but when I check python --version on my terminal it confirms I have python 3.7. However, when I check my pip path it gives me pip 20.1.1 from /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pip (python 3.8). Also, I am currently using VScode as my editor, and when I check sys.version_info in my app script it gives me version 3.8 as well. I tried creating a virtual environment in new file, double checking the package.json with 3.7, but when I run sys.version_info it still gives me 3.8 (I am still a beginner at using shell/terminal so I am confused as to why since my python version is 3.7 on my shell).
I worried about doing a complete uninstall of python and pip since I've read it could mess up the paths and cause complications repairing. How can I change the pip path to python 3.7 or have my script run 3.7 so that I can use pyinstaller on my macOS?

Using Spyder with Python 2.7 and Python 3 on Linux

I am working on a Python 2.7 program. I am not used to use Spyder, I usually use vanilla Python form the terminal. Since my calculation are quite heavy I would like now to use Spyder just to do the plotting without having to run the whole calculation. Basicly I want to use the Spyder because it keeps the variables in a workspace and because it provides the possibilty of messing around with the plotting without having to run a full calculation every time.
I installed Spyder with
sudo apt install spyder
How should I use this installation to choose whether Python 2.7 or Python 3?
What I tried
I also tried to install Spyder throught pip as suggested here like so
python -m pip install spyder
which is not working. So I forced pip to install a specific version of Spyder with
sudo pip install -Iv spyder==2.3.9
but again there is an issue with dependencies. And even if it had worked, it wouldn't have allowed me to select the version of Python. It would only have installed a version of Spyder that works with Python 2.7.
Changing Python interpreter as suggested here doesn't work either. I tried to specify bin/python as Python interpreted but it doesn't work with the IPython kernel.
Solution
As mentionned below the solution is to use conda and virtual environments for each Python version.
I'm not sure if I got your question right,
but if you are not sure how to change the Python interpreter in Spyder, then take a look into this post: How to change python version in anaconda spyder
If you want to run spyder,
just type spyder into your terminal.
If you want to use multiple versions of python consider to use virtual environments created by virtualenv or conda.
For this, take a look into this article: Conda: Creating a virtual environment
Rgds

How to install python3.7.0?

I am running a program on ubuntu that requires python 3.7.0, and I dont know how to install it
I have tried anaconda and created an environment, but it didn't work
I have also tried to install python 3.7.0, but when I do python -V, the version is still the 3.6.2 version.
Very interesting things happen.
When I install python3.7, and changed it as the default interpreter, the terminal won't open anymore. I had to change the default back to 3.6 to get terminal to open.
Anyway, I was able to create a virtual environment using anaconda and it works fine. Thank you all for you help

Categories

Resources