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
Related
In order to install older version of keras, tensorflow 1.10.0 is needed. That should solve compatibility issues with an algorithm I am trying to run. TO be able to install these older versions of tensorflow and keras and older version of python is required. I have tried to work with different algorithm using my linux system, terminal and have not been successful so far. I wish to know how to downgrade my current python version (replacing my version on the OS system or through a virtual environment) to python 3.5.6 or even 2.7.
The code I am trying to run is FSA-Net at https://github.com/shamangary/FSA-Net
I am trying to run the demo 'sh run_demo_FSANET.sh' after cloning to my local computer.
I do not use anaconda. I use pip.
I could not install Pyenv on my ubuntu.
I also donot have brew I have qbrew, which does not follow with the other commands suggested at How to downgrade python from 3.7 to 3.6.
Thank you in advance.
You can have multiple versions of Python at the same time.
First, install your python ver (alongside your present version):
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install python3.5.6
Then create & setup your project:
cd your_project
# Create venv
python3.5 -m venv venv
# Source
source venv/bin/activate
# Install everything you need
pip install {package_name}
That's it! You should be good to go.
NOTE: you did not specify what version of Linux you have,
so I assumed it's Ubuntu. But the process should be the same for the other versions of Linux also (just different commands).
I am using Ubuntu 18.04 in my work computer. I have never used Python2 versions before and it was annoying me to have in my computer because whenever I try to install something related Python I got issue even my default version Python3.6
I could not install pip, I could not install some packages so I wanted to delete Python completely from my computer. However now I can not install any python and getting lots of errors while trying several methods which are shared before on this platform and other websites.
Currently my terminal does not work so I use Xterm.
python --version
bash /usr/lib/command-not-found: /usr/bin/python3: bad interpreter: No such file or directory
whereis python
python: /usr/lib/python2.7 /usr/local/lib/python2.7 /usr/share/python /usr/share/man/man1/python.1.gz
sudo apt install python-minimal
sudo apt --fix-broken install
sudo apt update
I have tried many things I have seen on the web but could not fix. Also I am user in this computer so I do not have root access. Just wanted to know how to fix.
I'm trying to install an older version of tensorflow and it needs python3.6 to support the whl file of installation.
I'm now running Ubuntu 20.04 with python 3.8.5, I've already done this :
sudo add-apt-repository ppa:deadsnakes/ppa
followed by :
sudo apt-get update
sudo apt-get install python3.6
By doing that it installs python 3.6 but when I see the version of python installed it's still 3.8.5. Should I do something to remove python3.8.5 ? maybe apt-get purge ?
P.S: I'm installing the wheel file through pip3 should I downgrade it too ?
You shouldn't hack the system installation of Python I'd say.
Instead you should use something that let's you manage multiple versions of it, something like pyenv.
It is a well-known and widely accepted utility and according to its readme:
pyenv lets you easily switch between multiple versions of Python. It's simple, unobtrusive, and follows the UNIX tradition of single-purpose tools that do one thing well.
You can find the installation instructions here: https://github.com/pyenv/pyenv#basic-github-checkout.
Once you installed it you can install your preferred Python distribution which will live besides your system one and all the others you want later.
E.g. if you want to install 3.6.7 and then use it globally you can do:
pyenv install 3.6.7
pyenv global 3.6.7
Then test it like:
python -V
And that's only to scratch the surface, you can do many more things with it, check out the documentation for more.
after the commands you've run, you should have a python3.6 binary installed on the path
that said, I'd recommend using virtualenvs instead of system installations
for deadsnakes, you can install the venv module by (sudo) apt install python3.6-venv (debian decided to split venv into a separate module, so the deadsnakes packaging follows that)
from there you can create and activate a virtualenv:
python3.6 -m venv venv # create the environment
. venv/bin/activate # activate the environment
pip install ... # install things to your isolated environment
inside this virtualenv the python command will refer to your own isolated python installation
disclaimer: I'm the maintainer of deadsnakes
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 !
There are python 2.7 and python 3.2 on my computer. The default version is 2.7 because using python -V gives 2.7 as the version.
But when I use apt-get install numpy, scipy,pip why it install them into the python3.2 folder. After that I used pip to install the module into the 3.2 folder.
I also installed Theano this way but in the end it showed a message saying that there is no module named Theano installed although it is in the python 3.2 folder.
You haven't told on which OS you're running this, but it look likes a debian base linux, maybe ubuntu?
If so, I'd try with:
sudo apt-get install python3-numpy or
sudo apt-get install python2-numpy.
This would also work with python-pip2 and python-pip3.
After this, you could effectively use "pip2" or "pip3" to install your packages without having to go through the OS "prebuild" modules (but the os version of the packages are usually my prefered way to install them, if the exists in the repo)
Depending on what you're doing with python, it's often a good idea to run in a virtual environment, this lets you have several different versions of python with several different sets of installed packages on the same system. . .
See http://docs.python-guide.org/en/latest/dev/virtualenvs/ for the details.
You can also use Anaconda for maintaining two versions of Python. Anaconda consists of various libraries so you don't have to install them and after switching it to the different version of Python you can easily install them :
Download Anaconda for both Python versions
Open .bashrc
Add the path to new Anaconda you have installed for, e.g.:
export PATH="/home/paras/anaconda3/bin:$PATH"
Now there will be 2 export paths: one for Python 2 and one for Python 3. Comment the one which you don't want.
First install different versions of python or whichever python version you would like to use
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.6 10
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 20
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.3 30
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.4 40
Now create virtualenv like this and give the path of python version you want to use inside the virtualenv.
virtualenv -p /usr/bin/python3.6 <foldername>
virtualenv -p /usr/bin/python3.4 <foldername>