pip uninstall: "No files were found to uninstall." - python-3.x

I have created a python module, call it 'foo_bar'.
I can install it and I can upgrade it, but I cannot uninstall it.
I build my module using bdist_wheel:
$ python3 setup.py bdist_wheel
And I install and upgrade it as follows:
$ python3 -m pip --timeout 60 install --upgrade dist/foo_bar-1.4.3-py3-none-any.whl
It is listed within Python 3.4 framework directory:
ls -al /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/
drwxr-xr-x 12 samwise admin 408 Jun 21 02:50 foo_bar
drwxr-xr-x 9 samwise admin 306 Jun 21 02:50 foo_bar-1.4.3.dist-info
And it listed within pip freeze:
$ python3 -m pip freeze
foo-bar==1.4.3
However, if I try to perform pip uninstall, it cannot find it's files
$ python3 -m pip uninstall foo-bar
Can't uninstall 'foo-bar'. No files were found to uninstall.
Did I do something wrong within my setup.py for it not to be able to find my modules files during uninstall?
Version info is as follows:
$ python3 --version
Python 3.4.4
$ python3 -m pip --version
pip 8.1.2 from /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages (python 3.4)

I had the same issue. Using verbose helped me to find out a bit more the reason:
$ pip3 uninstall --verbose my-homemade-package
Not sure how to uninstall: my-homemade-package e48e635 - Check: /home/olivier/my-homemade-package
Can't uninstall 'my-homemade-package'. No files were found to uninstall.
Removing everything that was 'my-homemade-package' related in /usr/local/python2.x and /usr/local/python3.x did not help.
I did a pip3 show my-homemade-package and got the location of the installed package on my computer:
$ pip3 show my-homemade-package
Name: my-homemade-package
Version: e48e635
Summary: My Home Made package
Home-page: UNKNOWN
Author: UNKNOWN
Author-email: UNKNOWN
License: Proprietary
Location: /home/olivier/my-homemade-package
Requires: pyOpenSSL, pyasn1, protobuf
Removing /home/olivier/my-homemade-package sorted it out the issue (ie: the package was not listed).

This is an old post, but it was top result in Google. The above answers are correct, however, in my case there was still line /usr/local/lib/python3.6/site-packages/easy-install.pth that I had to remove after also removing the egg files.

So I was having a similar issue to OP. I could install my package with pip install dist/mypackage.tar.gz. Installation would work fine, but at the end it would show Can't uninstall 'mypackage'. No files were found to uninstall., and indeed pip uninstall mypackage wouldn't work later on.
It sounds silly but what worked for me was to change working directory: once I left mypackage/ directory, pip uninstall mypackage worked.

I had such issue when I renamed my module in setup.py.
Old old_name.egg-info directory still existed in my_module directory. So, when I installed module with pip install -e . pip created a line in python3.8/site-packages/easy-install.pth pointing to module directory. After that module was listed by pip list with both names: new-name and old-name. And when I tried to remove old module with pip remove old-name pip showed error:
Found existing installation: old-name 0.3.0
Can't uninstall 'old-name'. No files were found to uninstall.
The solution was to remove directory old_name.egg-info from module directory. After that pip list shows only new-name.
Probably it is not direct answer to original post but one of the solutions for issue in topic-name.

Issue: User cannot uninstall a python package installed via pip:
pip uninstall youtube-dl
Found existing installation: youtube-dl 2021.12.17
Not uninstalling youtube-dl at /usr/lib/python3/dist-packages, outside environment /usr
Can't uninstall 'youtube-dl'. No files were found to uninstall.
Reason: PEBKAC.
Well, a simple
apt purge youtube-dl
did the trick. There had been a system package "youtube-dl" installed, with said version:
dpkg -l youtube-dl
ii youtube-dl 2021.12.17-1~nd110+1
At the same time users used to install packages locally using pip. Both packages of the same version (2021.12.17). And both ways (apt and pip) referred to the packages by the same name. Turned out, this tends to confuse users..
Next level: Have a package installed three ways: apt, pip --system and plain pip as user. Maybe pip as root (locally) FWIW, too.

Related

Remove all pip packages

I'm using Linux/Manjaro KDE.
Since I was not familiar with Venv I installed more than 50 packages in my global and not everything is conflicted.
In order to clean up all pip packages I tried this command:
pip freeze | xargs pip uninstall
and even this one:
python -m pip freeze > requirements.txt
python -m pip uninstall -r requirements.txt
In both cases I get this error:
ERROR: Cannot uninstall 'apparmor'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
and then the progress will be interrupted.
Any solution?
I could remove everything like this:
To get room permissions:
sudo su
and then removed anything on this location:
/usr/local/lib/python3.9/site-packages/

Installed python package with `pip3`, but when I call it I get "No module named X"

I installed a module like this:
> pip3.8 install mssql-cli
but when I run it I get:
> 3002 ~$ mssql-cli -S 192.168.7.50 -d test-db
/usr/bin/python: No module named mssqlcli
I think mssql-cli is defaulting to the system--default python (2.x). How do I tell it to use python3.8?
Yes, I'm on a Mac. Python 3.8 is installed via Homebrew.
Answering questions from comments:
What does pip3.8 --version say?
3044 ~$ pip3.8 --version
pip 20.1.1 from /usr/local/lib/python3.8/site-packages/pip (python 3.8)
And check that which python3.8 points to /usr/local/lib/python3.8/python?
Not exactly. Is that bad?
3048 ~$ ll `which python3.8`
lrwxr-xr-x 1 grantb admin 40 Jul 24 10:57 /usr/local/bin/python3.8# -> ../Cellar/python#3.8/3.8.5/bin/python3.8
The issue is that if you look at the actual mssql-cli file it runs it using the python command. This (on my Mac) defaults to the 2.7 python. There are three solutions:
Add a line in your .bashrc or .bash_profile that says alias python='python3.8'. Note that this will override your python2.7 (which is obsolete anyway).
Edit the last line of the file that comes up with which mssql-cli to say python3.8 -m mssqlcli.main "$#". This has the disadvantage that you aren't really supposed to edit this, and that you'd need to do it every time you update this package, but it does work.
Run each mssql-cli command with the equivalent python3.8 -m mssqlcli.main.
Yet another brave soul caught up in the tangled web of installing Python on a Mac.
Your problem is that homebrew installed a version of Python in /usr/local/Cellar/python#3.8/3.8.5/bin/python3.8. Pip3.8, on the other hand, thinks Python is at /usr/local/lib/python3.8/python, so it installs its packages in that python's site-packages directory.
If you already had python with pip installed when you installed it from the Homebrew bottle, it won't overwrite the links you already had. One solution is to reinstall pip through the correct python.
python3.8 -m pip install -U --force-reinstall pip
This should force a reinstall of pip, and since python3.8 points to Homebrew's Python, it should install pip and pip3 as pointing to that python.

Can't update Python from 3.6 to 3.7 in MacOS

I have tried several commands to update python 3.6 to python 3.7 in homebrew on MacOS.
I have tried (as administrator user):
brew update
This claimed to install python 3.7
brew upgrade
brew link python3
brew link --overwrite python3
brew unlink python && brew link python
brew switch python 3.7.0
brew switch python 3.7.5
Cleaning /usr/local/Cellar/python/3.7.5
24 links created for /usr/local/Cellar/python/3.7.5
After all those attempts, I still get this:
python3 --version
Python 3.6.5
Can someone please help me to get switched over to python3?
Based on the comment:
which python3 -> /Library/Frameworks/Python.framework/Versions/3.6/bin/python3
Your python3 is not the same one installed/managed by Homebrew.
(Maybe it's from a Python .pkg installer for Mac?).
First, install it via Homebrew:
$ brew uninstall python3 # let's start from scratch
$ brew install python3
Check where it's installed:
$ brew info python3
python: stable 3.7.5 (bottled), HEAD
...
==> Caveats
Python has been installed as
/usr/local/bin/python3
Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, have been installed into
/usr/local/opt/python/libexec/bin
If you need Homebrew's Python 2.7 run
brew install python#2
You can install Python packages with
pip3 install <package>
They will install into the site-package directory
/usr/local/lib/python3.7/site-packages
...
Notice that Homebrew installed it at /usr/local/bin/python3 and the site-packages are stored at the corresponding /usr/local/lib/python3.7/site-packages.
Next, you need to make sure your OS looks for python3 at that same path.
$ echo $PATH
/usr/local/sbin:/usr/local/opt/openssl/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
If you don't see /usr/local/bin there, add it to your PATH by adding this to your ~/.bash_profile:
export PATH=/usr/local/bin:$PATH
Then source the updated ~/.bash_profile (or restart your Terminal).
$ source ~/.bash_profile
$ echo $PATH
From the comment, if your PATH shows /Library/Frameworks/Python.framework/Versions/3.6/bin/python3, you'll either have to remove it by explicitly setting the full PATH in your .bash_profile or make sure it comes after Homebrew's Python in /usr/local/bin.
Finally, check that python3 is now correct:
$ which python3
/usr/local/bin/python
$ ls -l /usr/local/bin/python
lrwxr-xr-x 1 gino admin 38 Oct 4 17:35 /usr/local/bin/python3 -> ../Cellar/python/3.7.5/bin/python3
$ python3 -V
Python3.7.5
Notice that python3 should be the python3 installed by Homebrew in the ../Cellar directory.
Can I easily change to the homebrew installation, or will I lose all my installed packages?
I would recommend re-installing the packages over at Homebrew's python3's site-packages folder. If you maintained a requirements.txt file for your Python projects, it's as simple as:
$ python3 -m pip install -r requirements.txt
The final solution was that Python 3.7 was already installed and could be accessed using the command python3.7.

pip3 install error when I use virtulenv as general user

I found the following problem when I tried to install the package using the pip3 command in a virtual environment.
source /bin/activate ##activate virtualenv
pip3 install aiohttp ##
error: Could not install packages due to an EnvironmentError: [Errno
13] Permission denied:
'/home/yxs/venv/py34/lib64/python3.4/site-packages/multidict' Consider
using the --user option or check the permissions.
pip3 install --user aiohttp
error: Can not perform a '--user' install. User site-packages are not
visible in this virtualenv.
So, I tried sudo pip3 install aiohttp,When I checked with pip3 list, I found that aiohttp was installed in the system. Beacause
(py34) [yxs#yxs ~]$pip3 list ## no package named aiohttp
[yxs#yxs ~]$pip3 list ## found aiohttp
How can I install packages into virtualenv?
Edit:
The operating system is CentOS7.5, the default Python version is 2.7, I installed python3.4 through epel-realse, pip3 installed by get-pip.py.
I guess the problem is that I have to use command sudo to install, but this command will leave the virtualenv environment. Just like the following, but I don't know how to solve this problem. By the way, these operations are excuted in the tmux session.
(py34) [yxs#yxs ~]$su - root
Password:
Last login: Wed Sep 19 12:07:23 CST 2018 on pts/2
[root#yxs ~]#
All in all, I can only use root to install the package into virtualenv by command pip install
Source /bin/activate means you're using /bin root directory of unix/linux.
As you're using python 3. Why don't you use python's builtin venv module.
Add .env directory into your .gitignore file.
Usage
python3 -m venv .env
source .env/bin/activate
pip install django
pip freeze > requirements.txt

Python3 wheel returns error : not a supported wheel on this platform

I would like to install wxPython/4.0.1
On this page all kind of wheel files are shown. I have Ubuntu 14.04 64 bit and Python 3.5 so I assume I should use wxPython-4.0.1-cp35-cp35m-win32.whl but this is not total clear to me.
The page lacks a simple full installation instruction.
#nepix32 helped me and shown the Linux version https://wxpython.org/pages/downloads/ and I have been pointing to https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-14.04/
apt-get
My preference is using apt-get, so I search on SO and found : Installing wxpython on ubuntu 14.04 and using travis-ci with wxpython tests
which both fails.
So I continue searching on wheel.
Install wheel
So I continue searching on wheel. On SO I found : How do I install a Python package with a .whl file?6
First I read https://stackoverflow.com/tags/python-wheel/info and https://pypi.python.org/pypi/wheel
Wheel seems not standard installed, so I downloaded the file wheel-0.30.0 and extracted it.
First I upgraded pip :
sudo pip install --upgrade pip
and then executed the setup.py in wheel :
sudo python3.5 setup.py install
which seems successful.
Try to install wxpython using wheel
Then I wanted to install the wheel file :
sudo pip install /home/hulsman/Downloads/wxPython-4.0.1-cp35-cp35m-win32.whl
I thought for python3.x pip3 should be used, instead of pip. All examples show pip. I tried both without success.
I tried also :
sudo -H pip3 install /home/hulsman/Downloads/wxPython-4.0.1-cp35-cp35m-win32.whl
All attemps returned almost the same error message :
wxPython-4.0.1-cp35-cp35m-win32.whl is not a supported wheel on this platform.
Using specific Linux version
I used
wxPython-4.0.1-cp35-cp35m-linux_x86_64.whl
but do not know the difference of the 'm' and the 'mu' version. The result is :
sudo pip install /home/hulsman/Downloads/wxPython-4.0.1-cp35-cp35m-linux_x86_64.whl wxPython
The directory '/home/hulsman/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/hulsman/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
wxPython-4.0.1-cp35-cp35m-linux_x86_64.whl is not a supported wheel on this platform.
hulsman#vbox11:~/Downloads$
and with the -H flag :
hulsman#vbox11:~/Downloads$ sudo -H pip install /home/hulsman/Downloads/wxPython-4.0.1-cp35-cp35m-linux_x86_64.whl wxPython
wxPython-4.0.1-cp35-cp35m-linux_x86_64.whl is not a supported wheel on this platform.
hulsman#vbox11:~
Check my environment
$ pip -V | grep -o "(.*)"
(python 3.4)
Pip points to Python3.4
$ pip3.5 install -i https://localhost --trusted-host localhost cffi==1.11.4
pip3.5: command not found
pip3.5 does not exist
$ python3.5 -c "import pip; print(pip.pep425tags.get_abbr_imp())"
Traceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: module 'pip.pep425tags' has no attribute 'get_abbr_imp'
This fails. So I tried :
$ python3.5 -c "import pip; print(pip.pep425tags.get_abbr_impl())"
cp
So I tried to update pip :
~$ pip install -U pip
Requirement already up-to-date: pip in /usr/local/lib/python3.4/dist-packages
I tried to follow the suggestions in Install pip for python 3.5 of L. Martin, but without success.
with pip3 the behavior is the same.
Could you tell me what when wrong, and how can I solve this?
Installing wxPython in Linux is not as straightforward as Windows/OSX wheels because there are too many variants: distro, GTK2/GTK3 etc. But they do explain how to install it in Linux:
https://wxpython.org/pages/downloads/
Installing with a downloaded wheel
You already found the correct wheel (cp35m-linux_x86_64) in wxPython Extras, but you must install it with the targeted Python version. If you can't find pip for your target Python, just use the -m option of Python:
python3.5 -m pip install wxPython-4.0.1-cp35-cp35m-linux_x86_64.whl
Installing the usual way from pypi
The normal pip install method can work too, but for wxPython in Linux, that will try to build the wheel for you from the source archive - assuming you have all the dependencies. It will be inconvenient, and slow.
Again, you must run it with the correct targeted version of Python:
python3.5 -m pip install -U wxpython
Installing directly from wxpython.org wheels (recommended)
The easiest way is to get it directly from them:
python3.5 -m pip install wxPython -U --pre \
-f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-14.04
Or, if you just wanted to download the correct wheel to manually install later, and specifically wanted to target a specific python version, say 3.5:
pip download wxPython \
-f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-14.04 \
--only-binary=:all: \
--platform linux_x86_64 \
--abi cp35m \
--python-version 35 \
-d "${HOME}/pymodules/wxpython-py35-whl"
Change the distro in the url as needed. Note that the pip version is not important here.
The difference in 'm' and 'mu' is no longer relevant in Python 3. It was related to ucs2/ucs4 unicode build flags. If you were targeting Python 2.7 you would use the abi option to pick the 'mu' version like this: --abi cp27mu
Since pip 19.2 added a new debug command, these kinds of obscure issues may get easier to diagnose. That useless not a supported wheel on this platform message certainly didn't help anyone.

Resources