I want to switch my python version from 3.9.6 to 3.10 in paperspace. But it doesn't work.
So I need your help.
device info
$root#nu1mmmnfz5:/notebooks/LoRA# cat /etc/*release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.5 LTS"
NAME="Ubuntu"
VERSION="20.04.5 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.5 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
$root#nu1mmmnfz5:/notebooks/LoRA# which python
/usr/local/bin/python
$root#nu1mmmnfz5:/notebooks/LoRA# ls /usr/local/bin/ | grep python
ipython
ipython3
python
python3
$ apt -y install python3.10
これが上手く入らないので苦戦しておりました。
$ python -V
Python 3.9.16
$ which python
/usr/local/bin/python
$ which python3
/usr/local/bin/python3
$ which python3.10
/usr/bin/python3.10
There are two, 'usr/local/bin' and 'usr/bin', and 'apt -y install python3.10' has gone into 'usr/bin'.
Tried
$apt update -y
$apt upgrade -y
$apt -y install python3.10
update-alternatives
You can install pyenv and you will be able to switch versions at will.
https://github.com/pyenv/pyenv
the best practice is not to change the system python version manually since many system services depend on it.
Also you should not install personal package using pip with root privilige for the same reason unless you know what it does.
you can use a version management to control the python env list like pyenv or conda
you can use update-alternatives to control python version
https://linuxconfig.org/how-to-change-from-default-to-alternative-python-version-on-debian-linux
maybe you should set the priority 0 or the same number
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.11 0
sudo update-alternatives --config python
[sudo] password for wz:
There are 2 choices for the alternative python (providing /usr/bin/python).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/bin/python3.11 0 auto mode
1 /usr/bin/python2.7 0 manual mode
* 2 /usr/bin/python3.11 0 manual mode
Press <enter> to keep the current choice[*], or type selection number: 1
update-alternatives: using /usr/bin/python2.7 to provide /usr/bin/python (python) in manual mode
Related
I am currently running python 3.6 on my Mac, and installed the latest version of Python (3.11) by downloading and installing through the official python releases. Running python3.11 opens the interpreter in 3.11, and python3.11 --version returns Python 3.11.0, but python -V in terminal returns Python 3.6.1 :: Continuum Analytics, Inc..
I tried to install again via homebrew using brew install python#3.11 but got the same results.
More frustrating, when I try to open a virtual environment using python3 -m venv env I get
Error: Command '['/Users/User/env/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.
I altered .bash_profile with
# Setting PATH for Python 3.11
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.11/bin:${PATH}"
export PATH
. "$HOME/.cargo/env"
And created a .zprofile based on this post with
export PYTHONPATH=$HOME/Users/User
and a .zshrc based on this post, but --version still throws python3.6.
I'm running Big Sur OS. Pip and homebrew are up to date and upgraded. Acknowledging that I'm totally foolish, what do I need to do to get python >3.7 running in terminal?
What you want to do is overwrite a python symlink.
After installing python via homebrew, you can see that python3.11 is just symlink.
cd /usr/local/bin; ls -l | grep python3.11
The result is:
lrwxr-xr-x 1 user admin 43 Nov 7 15:43 python3.11# -> ../Cellar/python#3.11/3.11.0/bin/python3.11
So let's just overwrite it.
ln -s -f $(which python3.11) $(which python)
ln -s -f $(which python3.11) $(which python3)
ln -s -f $(which pip3.11) $(which pip)
ln -s -f $(which pip3.11) $(which pip3)
After these commands, pip, pip3, python3, python will invoke the version 3.11.
This command makes soft symlink.
ln -s
This command with -f option overwrite an existing soft symlink.
A soft symlink is similar to a shortcut.
In man page,which command is described as
which - shows the full path of (shell) commands.
I have Python3.6 and Python3.8 installed on Ubuntu 18.04. When I execute python3 -V I get python3.8.0, which is correct. That's currently my default Python.
I used the Ubuntu 18.04 package repository when I installed Python3.6 and Python3.8. I just built Python3.10 from source and I want to set that as the default now. The canonical way to change is with --update-alternatives, but I did not do that when I installed Python3.6 and Python3.8, so when I execute:
update-alternatives --query python
update-alternatives: error: no alternatives for python
Python3.8 is in /usr/bin/python3.8 and Python3.10 is in /usr/local/bin/python3.10.
According to what I have read on the net, I should do this:
$ sudo update-alternatives --install /usr/local/bin/python python /usr/bin/python3.8
$ sudo update-alternatives --install /usr/local/bin/python python /usr/local/bin/python3.10
Then I select the default with sudo update-alternatives --config python.
Because I currently don't have any alternatives but I was somehow able to switch from Python3.6 to Python3.8 (I don't remember how), will the commands above cause any problems? Is there a problem in the different locations for 3.8 (/usr/bin/) vs 3.10 (/usr/local/bin/) and what will be the effect of the symlink for 3.10 going into /usr/local/bin/ where it's already located.
Naturally I could just try it, but if there is an issue I'm not sure how to back out of it if it goes wrong. I've gotten a lot of differing information on the net.
Thanks for any help.
I have answered my own question. First, I did have alternatives, but as Ubuntu defaults to Python2 (please Ubuntu change that -- the world has moved on), the command is sudo update-alternatives --config python3:
$ sudo update-alternatives --config python3
There are 2 choices for the alternative python3 (providing /usr/bin/python3).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/bin/python3.8 2 auto mode
1 /usr/bin/python3.6 1 manual mode
2 /usr/bin/python3.8 2 manual mode
Note the line "providing /usr/bin/python3." That means the Python symlinks for Python 3 are in /usr/bin/python3. So I add the new one:
sudo update-alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.10 3
That makes Python 3.10 priority 3, the highest priority. Then:
$ python3 --version
Python 3.10.0
I hope that helps someone in the future.
I installed Python 3 using the Cygwin terminal. There were no issues during installation.
I get this:
$ which python3
/usr/bin/python3
and
$ whereis python3
python3: /usr/bin/python3 /usr/bin/python3.6 /usr/lib/python3.6 /usr/lib/python3.8
/usr/include/python3.6m /usr/include/python3.8 /usr/share/man/man1/python3.1.gz
But neither of
$ python3 $ python3 main.py $ python3 --version
give any output. I have done this the same way before on the same computer and it worked fine. What did I do wrong this time? Or forgot to do?
Try to create an alias to attach python to the common name "python3". In your Cygwin terminal write:
$ alias python3=$(which python3.6)
python3 should be a link managed by alternatives pointing to python3.8
$ alternatives --display python3
python3 - status is auto.
link currently points to /usr/bin/python3.8
/usr/bin/python3.6 - priority 36
/usr/bin/python3.7 - priority 37
/usr/bin/python3.8 - priority 38
Current `best' version is /usr/bin/python3.8.
that belongs to python38 package
$ cygcheck -f /usr/bin/python3.8
python38-3.8.7-3
verify that python38 is correctly installed
$ cygcheck -c python38
Cygwin Package Information
Package Version Status
python38 3.8.7-3 OK
and that there are no issue on the dependency
$ cygcheck /usr/bin/python3.8.exe
D:\cygwin64\bin\python3.8.exe
D:\cygwin64\bin\cygwin1.dll
C:\WINDOWS\system32\KERNEL32.dll
C:\WINDOWS\system32\ntdll.dll
C:\WINDOWS\system32\KERNELBASE.dll
D:\cygwin64\bin\libpython3.8.dll
D:\cygwin64\bin\cygintl-8.dll
D:\cygwin64\bin\cygiconv-2.dll
D:\cygwin64\bin\cyggcc_s-seh-1.dll
More likely you need to re-install python38 or one of the needed libraries
$ cygcheck -f /usr/bin/cygwin1.dll /usr/bin/cygintl-8.dll /usr/bin/cygiconv-2.dll /usr/bin/cyggcc_s-seh-1.dll
cygwin-3.1.7-1
libgcc1-10.2.0-1
libiconv2-1.16-2
libintl8-0.19.8.1-2
be sure to stop all Cygwin processes before re-installing the packages; specially any running service
I installed python 3.8 in my kali linux OS, but when I type python in kali linux terminal it showing like this
> Python 2.7.18 (default, Apr 20 2020, 20:30:41)
How can I set Python 3.8 as my default?
Hope this answers your question.
The easiest way would be to run alias python=python3 .
So, now if you run the command python it will load python3 instead of python while being under the same alias/command python.
What I usually do is install non-default versions of programs under /usr/local. Then I configure the file $HOME/.bash_profile so that the $PATH variable has /usr/local/bin first, before /usr/bin and /bin (which might actually be the same physical directory on your system).
$HOME/.bash_profile:
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
# PATH starts with...
PATH="/usr/local/bin"
# add $HOME/bin if it exists...
if [ -d "${HOME}/bin" ]; then
PATH="${PATH}:${HOME}/bin"
fi
# These should exist, add them as fall back....
PATH="${PATH}:/bin:/usr/bin:/sbin:/usr/sbin"
# Some custom locations last
if [ -d /usr/local/arm-elf/bin ]; then
PATH="${PATH}:/usr/local/arm-elf/bin"
fi
if [ -d /opt/local/bin ]; then
PATH="${PATH}:/opt/local/bin"
fi
This has the effect of making anything located in /usr/local/bin the default when I am using an interactive shell, and letting the system defaults remain in effect otherwise.
first, check if you have python3.8 installed
use
ls /usr/bin/python*
then check for an alternative python version using
update-alternatives --list python
if the output of python3.8 is set to 2
To set the default python command to run python3.8
use this to create a persistent symlink
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.8 2
the 2 depends on your python alternatives
then
python --version
First remove python 2.7.18
Type >> sudo apt purge -y python2-minimal
install python latest version
Type >> sudo apt install -y python3-pip
latest version of python is installed!
This question already has answers here:
Installed Python 3.8 on Ubuntu, but it's not the default
(3 answers)
Closed 2 years ago.
When I type python --version in my terminal, it shows Python 3.8.5, but when I type python3 --version, it shows Python 3.6.9. I want to create a virtual environment using python3 -m venv .venv with the version 3.8.5, but because of the fact that my default python3 version is the 3.6.9, it's creating a virtual environment using 3.6.9 as it's version. How do I change my default python3 version?
The python and python3 commands are usually soft links to the actual executables and you can change the targets. For example:
Firstly, find out where python 3.6 and python 3.8 are located:
# which python
/usr/bin/python
# ls -l /usr/bin/python
/usr/bin/python -> python3.8
# which python3
/usr/bin/python3
# ls -l /usr/bin/python3
/usr/bin/python3 -> python3.6
Then, change the soft links:
# rm /usr/bin/python3
# ln -s /usr/bin/python3.8 /usr/bin/python3
Run this Command in your terminal
sudo update-alternatives --config python
You'll get choice prompt, enter selection number of your desired python version.
But if this shows an error like this: update-alternatives: error: no alternatives for python3
Then you have to update your update-alternatives, then you will be able to set your default python version.
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6.9
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.8.5
Now run below command to set default python
sudo update-alternatives --set python /usr/bin/python3.8