My system is Ubuntu 14.04. I installed python 3.5.2 and used the command:
$ln -s /usr/local/python3.5.2/bin/pip/usr/bin/pip
to change the Soft Link of pip. But now, I use python 2.7 (System of binding) again. And my pip version is still python3.5.2.
What should I do to change the default pip link?
In a terminal,
sudo cp /usr/local/bin/pip2.7 /usr/local/bin/pip
ready !
Related
My setup is 2021 MBP with M1 Pro processor, macOS 12.5 and Xcode 13.4.1. I'm building an app using NativeScript and I can't release the app because every time I go to product > archive Xcode says "Python command requires the command line tools." When I agree to install it will look like it installed but then start over.
I reset my Mac and reinstalled macOS so a fresh setup was used. First I followed the suggestion from NativeScript docs (https://docs.nativescript.org/environment-setup.html#macos-ios) and ran sudo ln -s $(which python3) /usr/local/bin/python which created an alias for python 2.x. Then did python3 -m pip install --upgrade pip and python3 -m pip install six. Tested my configuration with ns doctor ios - it complained about missing python and Xcode dialog prompted me to install python. Click install, it finishes, running ns doctor ios and starting over.
While it seems like macOS 12.5 ships with python3 already none of the options worked me.
Later found an article where the author suggested installing python using pyenv. So I went that path, installed it globally and set env into my shell. Retested and got the same error.
Xcode-select -p results in /Applications/Xcode.app/Contents/Developer
I tried:
sudo ln -s /Applications/Xcode.app/Contents/Developer/usr/bin/python3 /Applications/Xcode.app/Contents/Developer/usr/bin/python
and
sudo ln -s /Library/Developer/CommandLineTools/usr/bin/python3 /Library/Developer/CommandLineTools/usr/bin/python
None helped. I also tried
sudo ln -s /Applications/Xcode.app/Contents/Developer/usr/bin/python3.8 /Applications/Xcode.app/Contents/Developer/usr/bin/python
as I noticed there's python3.8 in Xcode's folder but that didn't work either. I'm a bit confused why Xcode is looking for Xcode in it's own folder now and doesn't use python3 that comes with macOS.
I finally found a fix.
Steps I did to make it work:
Removed all symlinks I've set originally
Removed python installed via pyenv using pyenv uninstall 3.10.6
Ran brew uninstall pyenv to removepyenv
brew install python
python --version results in Python 3.9.13
And finally sudo ln -s $(which python3) /usr/local/bin/python
So essentially if you're on a new system do steps 4 and 6 and you should be good to go.
I am using python 3.7 in google colab, but for some reason when I am connected with a linux server in google cloud the python becomes 2.7. How can I change it? Note that python 3.7 is already installled in the server.
I tried these things but weren't helpful.
apt update
sudo apt install python3-pip
alias pip='pip3'
I checked also these sites https://cloud.google.com/python/docs/setup#linux_2, How do I install Python 3.7 in google cloud shell but didn't solve my problem.
Edit
By doing Runtime --> Change runtime I can see only this, which the options are 'non', 'gpu', 'tpu'.
You can check your Python version at the command line by running python --version. In Colab, we can enforce the Python version by clicking Runtime -> Change Runtime Type and selecting python3.
Python 2.7 is expected to be removed in Debian "testing", the basis of gLinux. This is expected to happen shortly after the next major version, Debian Bullseye, is released.
You need to migrate Python 2.7 code to Python 3 and remove python-is-python2 packages you might have installed.
When Python 2.7 is removed from gLinux, python-is-python2 will be uninstalled.
If you have software that requires /usr/bin/python to work, but can be used with Python 3, you should install python-is-python3.
You can change Python version by running the following commands in terminal:
pip install virtualenv
virtualenv venv --python=python3
This only works if you have Python2.7 installed at the system level (e.g. /usr/bin/python2.7).
You can find the path to your Python installation with
which python3
virtualenv venv --python=/usr/local/bin/python3
And check the version using python3 –version.
So actually the answer of my question comes from this post How to completely uninstall python 2.7.13 on Ubuntu 16.04.
Everyone who have a similar problem the first thing that he/she should do is to unistall python 2.7 by using either
sudo apt install --reinstall python python-apt python2.7-minimal
or
sudo apt purge python2.x-minimal
and then install python 3.7, by using
sudo ln -s /usr/bin/python3 /usr/bin/python
sudo apt install -y python3-pip
sudo ln -s /usr/bin/pip3 /usr/bin/pip
# Confirm the new version of Python: 3
python --version
I was able to install python 3.9.0 on raspberry 4 and I can verify through the terminal that that has been set as the default python. However, 3 different IDEs (idle, thorny and Microsoft visual code) that I am using cannot find the python 3.9.0 but can see 3.7.3 which came with the pi. I followed this (link) instruction but cannot tell why it is not working.
I will appreciate any help at all.
Thank you.
I'm not sure but for IDLE you may have to install it with
python3.9 -m pip install idle
or
apt install idle-python3.9
and you should have to run it as
idle-python3.9
so at the same time you should have
idle-python3.7
to run it with Python 3.7
thonny (similar to VS Code) has Tools > Options > Interpreter or Run > Select Interpreter.... You may also use
python3.9 -m pip install thonny
and it should even use python3.9 to run thonny
You should add Python's folder to existing PATH like
export PATH=/usr/local/opt/python-3.9.0/bin:$PATH.
As I remeber it has to be splited by : and it has to be = without spaces.
You can check
echo $PATH
before you set new value to see if it uses : to separate paths.
But usually it should create also links
/usr/bin/python3.7
/usr/bin/python3.9
/usr/bin/pip3.7
/usr/bin/pip3.9
so it should run without any changes in PATH.
At least I have these links on Linux Mint 20 (based on Ubuntu 20.04).
You can check if you have
ls -al /usr/bin/python*
ls -al /usr/bin/pip*
and also
which python3.7
which python3.9
which pip3.7
which pip3.9
or
whereis python
whereis pip
or formatted (new line instead of space)
whereis python | sed 's/ /\n/g'
whereis pip | sed 's/ /\n/g'
Eventually you could create link manually and then you don't have to add folder to PATH
sudo ln -s /usr/local/opt/python-3.9.0/bin/python /usr/bin/python3.9
or you could copy (not move) python to /usr/bin/python3.9
sudo cp /usr/local/opt/python-3.9.0/bin/python /usr/bin/python3.9
Every python version should have own pip to install modules only for this version - they don't share modules.
You have to install pandas in Python 3.9.0. Check if you have pip3.9
pip3.9 install pandas
or use directly python3.9 like
python3.9 -m pip install pandas
You could check
pip -V
pip3 -V
to see for what version they install modules.
BTW:
Stackoverflow has special page for Raspberry Pi
https://raspberrypi.stackexchange.com/
Raspberry Pi has also own official forum
https://www.raspberrypi.org/forums/
I am trying python --version in my windows subsystem for linux terminal and it is showing me 2.7.15 whereas I do not have 2.7 in my system. I have python 3.6 set in my environment variable, and that is the python interpreter I have used till date. Suddenly after restarting my system I could see that version is 2.7. How do I change the version of python and set it to my original interpreter ? I have tried sudo apt update && upgrade and then sudo apt install python3 python3-pip ipython3. Did not help. Please help.
Try python3 --version or python3.6 --version
Run these 2 commands
pip install --upgrade virtualenv
virtualenv -p python3 envname
You can use python3 as python3 orpython3.6
If you still want to use python3 with the python command, edit your ~/.bash_profile file and add line alias python='python3' and restart terminal
you can try using alternatives install python 3.6
and try
# alternatives --config python
and choose the alternative version
I have compiled and installed python2.6 on my system with python2.7 installed as well. Unfortunately, I did not do it correctly and now my default python is 2.6. When I enter
which python && /usr/bin/env python -V
I am given
/usr/local/bin/python
Python 2.6.9
How can I change this? I checked my $PATH variable, but anything relevant to python is not there. The desired version is
/usr/bin/python
Ideally, you should NOT change the default python on your systems. Too many things are dependent on it. HOwever, you can install a newer version and use it in your scripts. Here's is an abridged version of how to do this
DOWNLOAD AND INSTALL PYTHON 2.7
The Fedora system comes stock with Python 2.6. As I've learned, you do not want to remove/overwrite 2.6 as other system tools use it. So you will want to install it as an "alternate" version.
First download Python 2.7 from the Python Org download website!. At the time of this writing, the latest release is Python 2.7.6. All of these instructions assume you are doing these as root. You can alternatively use sudo.
NOTE: the final step is to use make altinstall. This is important.
wget http://www.python.org/ftp/python/2.7.6/Python-2.7.6.tgz
tar xvzf Python-2.7.6.tgz
cd Python-2.7.6
./configure --prefix=/usr/local
make
You can verify the installation:
[root#centos6_4_32 ~]# python2.7 --version
Python 2.7.6
make altinstall
DOWNLOAD AND INSTALL PIP
The pip tool is used to install Python modules (a.k.a. "packages", "libraries", etc.). You need to install the latest set of tools and ensure they are installed in the Python 2.7 area of you system. You do NOT want to use the stock pip tool since it will install in the Python 2.6 area. The following instructions were taken from this website. At the time of this writing, the latest version of pip is 1.4.1.
# copy the setup scripts
wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
wget https://raw.github.com/pypa/pip/master/contrib/get-pip.py
# now make sure you use python2.7 when installing
# these tools!
python2.7 ez_setup.py
python2.7 get-pip.py
NOTE: Ensure that you are using python2.7 when running these scripts, and not just python.
You can verify the installation:
[root#centos6_4_32 ~]# pip-2.7 --version
pip 1.4.1 from /usr/local/lib/python2.7/site-packages (python 2.7)
NOTE: use pip-2.7 and not just pip.
Source: http://forums.juniper.net/t5/Network-Automaniac/Installing-Python-2-7-on-CentOS-6/ba-p/217295