I recently installed Python 3.8 onto my computer. I now have Python 3.7 and 3.8. I would like to delete 3.7 but I don't want to mess anything up.
When I type 'python --version' in the Anaconda Prompt,
Python 3.7.9
I fear that if I uninstall 3.7, all the libraries in Anaconda will not work. How do I uninstall 3.7 and make sure that Anaconda "links up" with 3.8?
UPDATE:
I've since figured this out... I originally tried to install with 'conda update python' ... this does not achieve the update. I then downloaded 3.8 from Python's website. This seemed to mess up things. I then uninstalled all of Anaconda and then reinstalled it. By re-installing, Python 3.8 was installed and is working. For future updates, I am still not sure what the best way to update from 3.x to 3.y is as suggestions on other message boards did not seem to work.
I try to give you a comprehensive solution
If you want to update without removing you just need to switch the python3 to python3.8.
The way install python3.8 will be executed through ppa.
Then you can switch between version of python
sudo rm /usr/bin/python3
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 3
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.7 2
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.8 1
Choose python3 link with python3.8, then pip3 will point to python3.8
But if you remove python 3.7, you need to self configure pip again to have it point to an exact python version by
wget https://bootstrap.pypa.io/get-pip.py
python3 get-pip.py #which has been linked to 3.8
However, this processed is simple for virtual environment, you just need to config your own package of python by yourself choosing. You can install any environment by creating a new environment. Your python3.7 will be a base environment,
Thank you for sharing this. I literally just spent a day trying to update python version using conda but it goes into a seemingly endless loop of resolving conflicts. I also tried to install 3.8 directly but that did not work. The solution really was to just download and install the latest version of Anaconda.
Related
I have Ubuntu 18.04. I want to upgrade to python 3.x
When I do:
python --version
I get:
Python 2.7.17
But then I run:
sudo apt-get install python3
it says:
python3 is already the newest version (3.6.7-1~18.04).
I guess this means that I have more than one version of python on my laptop? What's the best way for me to clean this up? Should I delete one? I made a bit of a mess installing / uninstalling anaconda / miniconda at various points in my life, and so that has probably not helped.
I just want to have a clean install of python 3, and then I will reinstall miniconda after.
To run Python 3 instead of Python 2 type:
python3
If you want Python 3 to run by default you can add the following to the aliases section of your .bashrc:
# some more ls aliases
alias python='python3'
To update Python3:
sudo apt upgrade python3
I would like to uninstall all the python version installed and all packages on my MAC.
The python version I get is the following:
python --version
Python 3.7.3
However, I have Python 2.7 folder in Applications.
I also have installed Anaconda and the folder
/Users/myName/anaconda3
I would to uninstall Python 3.7.3 and all the packages I have installed both trough pypi and trough conda
I,once, deleted a python version completely from my mac by doing the following steps on the terminal:
sudo rm -rf “/Applications/Python”
sudo rm -rf /Library/Frameworks/Python.framework
sudo rm -rf /usr/local/bin/python
Then, when the password is prompted, enter it and confirm.
As, for anaconda, I remember deleting it once due to a problem using this software here:
https://nektony.com/mac-app-cleaner/download?productname=Anaconda
It's a download link, so be careful before you click incase you are thinking it contains information about the software etc.
My python version was 3.something, so I am not exactly sure whether it will help with the latest one but I thought my steps might help so I hope it helps :)
I did what Mahir said above, but I had Python 3.9 and the 3.8 that Anaconda had installed. I've uninstalled 3.9, but I couldn't find the folder where the 3.8 was. After some time I've found it inside the Command Line folder in this path here:
cd /Library/Developer/CommandLineTools/usr/bin
Then I deleted all the files/folders related to python with the command below:
sudo rm -rf pip3 pip3.8 pydoc3 pydoc3.8 python3 python3.8
Maybe you'll also have to do this to get rid of python
I've recently upgraded from Ubuntu 18.04 to 19.04 which has python 3.7. But I work on many projects using Python 3.6.
Now when I try to create a virtualenv with Python 36 in PyCharm, it raises:
ModuleNotFoundError: No module named 'distutils.core'
I can't figure out what to do.
I tried to install distutils:
milano#milano-PC:~$ sudo apt-get install python3-distutils
Reading package lists... Done
Building dependency tree
Reading state information... Done
python3-distutils is already the newest version (3.7.3-1ubuntu1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
But as you can see I have the newest version.
Do you know what to do?
Python base interpreter does require some additional modules. Those are not installed with e.g. Ubuntu 18.04 as default.
To solve this we need to first find the python version you're running. If you have only installed one python version on your system (and you are sure about it) you can skip this step.
# from your project interpreter run
# your_project_python --version
$ python3 --version
Python 3.7.8
You now need to install for this precise python interpreter the distutils.
So here the solution for this example would be:
sudo apt install python3.7-distutils
# sudo apt install python3-distutils # would just update default python intrpreter
Keep in mind, that just running python from any command line might be an other version of python then you're running in your project!
If this hasn't helped, look for the following possibilities. This will bring you the binary which resolved from the alias in the command line.
$ which python
/usr/bin/python
$ ls -lach /usr/bin/python
lrwxrwxrwx 1 root root 9 Jun 8 2018 /usr/bin/python -> python2.7
original source: refer to this article
For this answer I've also merged, summarized, ordered and explained some of the content which has been provided by Neo, Andrei, Mostafa and Wolfgang.
As a side note for sorcerer's apprentice: You might be tempted to uninstall python interpreters. For proposed solution not necessary at all!! How ever, keep in mind that there is one python interpreter which your whole OS depends on. So this default one, you don't want to uninstall. If you do so, you're in a certain mess in finding your desktop taskbar and basically everything.
If I have multiple versions of python3 (etc 3.8 as main and 3.9 from ppa:deadsnakes/ppa) on ubuntu 20.04 (in my case kubuntu 20.04) and it doesn't work
sudo apt install python3-distutils
then it works for me
sudo apt install python3.9-distutils
Other Cases
This happened on my python3.7 installation but not my main python3 after i upgrade my ubuntu to 20.04
Solution:
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt install python3.7
Currently, I'm using ubuntu 18.04 and python 3.6.9. My problem was solved after running the following command as mentioned here:
sudo apt-get install python3-dev
More Details: Some modules in python are needed that not installed.
For me the problem was solved by specifically using python3 thus making sure python3.8 was used
python --version
Python 3.7.5
python3 --version
Python 3.8.5
I still got error message after trying to install python3.9-distutils for python version 3.9 in pipenv.
As I noticed here python3.9-distutils is in conflict with earlier versions of that package and cannot be installed on Ubuntu18.04.
I move on by using python_version = "3.6" with pipenv otherwise $ pipenv install would take the highest version of python and write it in the Pipfile and Pipfile.lock.
$ pipenv --rm #To remove the old environment
$ rm Pipfile* #Remove both Pipfiles
$ pipenv install --python 3.6
What happened:
After an OSx update and installing a new version of python 2.7 my virtualevn environment completely broke and I struggled in fixing it. I wasn't sure what caused it and went through a whole set of things that I did and read initially that didn't work are listed below. What solved my problem is provided in the answer section.
What didn't work to fix virtualenv command not found:
Installed python through homebrew and then used pip to install virtualenv
Installed python through https://www.python.org and then used pip to install virtualenv
Related questions that helped me but did not provide the solution to my problem:
virtualenv-command-not-found
virtualenv-workon-command-not-found
Complete manual recovery I went through (What not to do!):
This didn't completely solved my problem. It is just to give you an idea of what steps I went through before I found the correct way to fix my python dev environment on my OSx.
Removed python 2.7 by using the post in here
Removed the homebrew installed version
Installed python through the pkg file in Mac OS X 32-bit i386/PPC installer or Mac OS X 64-bit/32-bit installer
Manually installed virtualenv following the instructions from here:
curl -O https://pypi.python.org/packages/source/v/virtualenv/virtualenv-13.1.2.tar.gz
tar xvfz virtualenv-13.1.2.tar.gz
cd virtualenv-13.1.2
sudo python setup.py install
Manaully install pip through 7:
curl --silent --show-error --retry 5 https://bootstrap.pypa.io/get-pip.py | sudo python2.7
PIP was still broken after all this:
After all this after creating a virtual environment my pip still installed the packages in the main python folder instead of installing them under the virtual environment and non of the threads here neither here helped. My solution to that was to run pip under my virtual env with the following options:
1- Activate the virtual environment so that $VIRTUAL_ENV is set:
source venv/bin/activate
2- Forces pip to install in the right destination:
pip install --target=$VIRTUAL_ENV/lib/python2.7/site-packages
Summary
Something was badly broken and best way I fix my dev environment is provided in the answer to this question.
The reason
In my case was an OSx upgrade that affected my homebrew and after upgrading to python 2.7.11 is didn't install it properly.
How I got it to work:
I found steps 3 and 4 in a thread here and many thanks to https://github.com/baronomasia.
1 - Removed python 2.7 by using the post in here
2 - Removed the homebrew python installed version
brew uninstall python
3- Reinstall your Xcode command tools:
sudo xcode-select --install
4- Upgrade homebrew and reinstall python through homebrew:
brew update && brew reinstall python
After doing brew upgrade python my system python was broken and was throwing fits about virtualenvwrapper.sh, as well as my pip command was just suddenly missing.
I went to python.org and downloaded the python 2.7.13 installer, ran it, I now have python 2.7.13, pip, and can run pip install virtualenvwrapper and things seem to work.
I ned to install spyder for python 3.4.
I used this link
with the following code
Requirements:
sudo apt-get install python-qt4 python-sphinx
Installing:
sudo pip install spyder
Updating:
sudo pip install -U spyder
But when I run spyder it opens python 2.7
Since the only one that shows the number of python is the first one, I guess the issue is related with sphinx (but don't know).
How can I link spyder to python 3.4 instead of 2.7?
Install with pip3 instead of pip. It may be beneficial to work in an isolated python 3 environment such as a venv, remember the system python is python 2. Have a look at the Dockerfile I use to set up my environment to see if that helps.
Using pip3's full path when calling it will also probably help. I'm on my phone rather than laptop so can't confirm right now.