How to uninstall python and all packages on mac? - python

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

Related

How to install Python 3.6+ version in Kali Linux?

I need help. I newone in Linux OS and in Python at all.
I need to install python interpreter v. 3.6 for my current project. The reason is - lib, that i would like to use doesn't work on 3.7+
I use Pycharm and want to set new environment with interpreter 3.6. I know that i can set it in settings/project/python interpreter. But i can see only python v2,v2.7,v3,v3.9.
How can i add 3.6 version? Please, help)
command apt install python3.6 doen't help me.
└─# apt install python3.6 2 ⨯
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package python3.6
E: Couldn't find any package by glob 'python3.6'
About OS:
└─# cat /etc/os-release 127 ⨯
PRETTY_NAME="Kali GNU/Linux Rolling"
NAME="Kali GNU/Linux"
ID=kali
VERSION="2021.1"
VERSION_ID="2021.1"
VERSION_CODENAME="kali-rolling"
ID_LIKE=debian
ANSI_COLOR="1;31"
HOME_URL="https://www.kali.org/"
SUPPORT_URL="https://forums.kali.org/"
BUG_REPORT_URL="https://bugs.kali.org/"
Serge Ballesta helped me. Thanks a lot!
Just for silly ubuntu users like me - "how to install some source distribution"
Extract the .tar.gz or (.tar.bz2) file with the following commands
tar xvzf PACKAGENAME.tar.gz
Navigate to the extracted folder using cd command
cd PACKAGENAME
Now run the following command to install the tarball
./configure
sudo make install
Not all Unix distributions offer all Python versions. It is common to only have one Python 2.7.x version and one or two Python 3.y .
Normally Python 3 has a good ascending compatibility, so a Python 3.9 should run a Python 3.6 without any problem. If you really need a specific version, the desperate way is to get a source distribution from python.org and build it locally. The downside is that this one will not participate in apt version control, so it will not be detected by third party application. But it is the only way I know to have a no longer distribution maintained version.
see details: https://pkg.kali.org/pkg/python3.6
[2019-02-05] python3.6 3.6.8-1 removed from kali-rolling (KaliRepository
[2019-01-28] python3.6 3.6.8-1 removed from kali-dev (Kali Repository)
as seen, python3.6 removed than the Kali repository.
please, download the python3.6 using following url
https://www.python.org/downloads/release/python-360/
First remove older version
sudo apt purge -y python2-minimal
Remove unwanted libraries of old version
sudo apt autoremove
install new version
sudo apt install -y python3-pip
latest version of python is successfully installed!
check version
python --version
You can write
$sudo apt-get update
and then run
$sudo apt-get python3.6

How to downgrade virtualenv from 20.4.2 to 20.0.1?

Currently, my python version is 2.7.16 and after I run pip install virtualenv then I enter python -m virtualenv venv then I get this error msg
"/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: No module named virtualenv"
But when I run pip freeze | grep virutalenv, I get virtualenv==20.4.2, which is the latest version. My guess is if I downgrade virtualenv to 20.0.1 then system will recognize virtualenv, since I'm using old python version. I looked around for documents, but there were no info on how to do this.
Does anybody know how to downgrade virtualenv version from mac terminal?
try
pip uninstall virtualenv
pip install virtualenv==20.0.1
My guess is it has to do with your python path, not at all with the version
try to nano ~./bash_profile
and
export PYTHONPATH=$PYTHONPATH:path/to/your/venv
then
source ~./bash_profile
The above is adding the path to the module to your python path so that python sees it

How do I upgrade to Python 3.8 with Anaconda?

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.

Running `pip` gives 'command not found' after successful Python homebrew install

To preface, I am very bad with the terminal, please be patient with me.
when I run pip I get:
zsh: command not found: pip
I have installed Python 2.7.11 with brew, which should allow pip to work
When I run echo $PATH I get
/usr/local/sbin /Users/Nicolas/.composer/vendor/bin /Library/Frameworks/Python.framework/Versions/3.4/bin /usr/local/bin /usr/bin /bin /usr/sbin /sbin
I notice that /usr/local/bin/ is in there, which I understand is where brew executables are linked to
when I run which -a python I get
/usr/local/bin/python
/usr/bin/python
So-- two Python installs. I'm guessing one is the native OSX one and one is the homebrew install.
When I run which python I get
/usr/local/bin/python
So this is the python that gets run when python is called, right?
When I run ls -l $(which python) I get
lrwxr-xr-x 1 Nicolas admin 34 Feb 3 14:26 /usr/local/bin/python -> ../Cellar/python/2.7.11/bin/python
I think this is where the problem is; I notice that there is a /python/2.7.11/libexec folder...
I have also tried brew unlink python && brew link python to no avail
when I try brew list python | grep pip I get a very long list of results
This is probably the most important one
/usr/local/Cellar/python/2.7.11/libexec/pip/pip/__init__.py
I don't know how to proceed from here... I think it has to do with pip being in python/2.7.11/libexec instead of python/2.7.11/bin
I am not familiar with most of this stuff; my understanding of terminal is very limited. I am not sure how to proceed from here. Any and all help is appreciated, thanks.
I ran into this problem myself on OS X. In my case, I finally did a listing of /usr/local/bin, and found that I had links from pip2, pip2.7, pip3, and pip3.6. What I lacked was a link from just pip. I don't know if this is just part of a new standard, or if I was missing something that would select one of the two, or if having both Python 2 and Python 3 installed meant that I didn't get a simple pip command. Either way, running brew doctor didn't reveal or solve any issues.
In this case, just running pip3 or pip2 (instead of pip) seemed to do the trick for me. In my case, I ran pip3 and everything installed and ran as expected.
My Background
I had this same problem, and I think it may have arisen after upgrading to OSX 10.11 (El Capitan). When trying to run pip, I got -bash: pip: command not found I also tried python -m pip which did not work either (no module found). Trying to unlink and relink python through Homebrew did not work.
The Fix
I was able to fix the problem by completely uninstalling and reinstalling python via Homebrew.
brew uninstall python && brew install python
If you want to remove older versions of python too, use
brew uninstall --force python && brew install python
None of my existing pip installs were affected, and are all still listed when I run pip freeze. After the reinstall, the binary is now symlinked to /usr/local/bin/pip, which did not exist before. Strangely, the actual binary in /usr/local/Cellar/python/2.7.11/bin/pip did not exist before the reinstall either.
Uninstalling/reinstalling did not fix it for me but brew provided this info:
Unversioned symlinks python, python-config, pip etc. pointing to
python3, python3-config, pip3 etc., respectively, have been
installed into /opt/homebrew/opt/python#3.9/libexec/bin
So adding /opt/homebrew/opt/python#3.9/libexec/bin to my path fixed the issue.

How to fix broken python 2.7.11 after OSx updates? An in-depth look into Homebrew and beyond

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.

Categories

Resources