28

I looked this up online but they're all suggesting using sudo command I used

sudo pip uninstall numpy

I get this message:

Not uninstalling numpy at /usr/lib/python2.7/dist-packages, outside environment /usr

I installed it using pip , not apt .

The output of :

 $ dpkg -S /usr/lib/python2.7/dist-packages/numpy
 python-numpy: /usr/lib/python2.7/dist-packages/numpy

PS: I'm a mac user, I usually use homebrew for my installations, so I'm an amateur in Ubuntu

momo12321
  • 381

8 Answers8

23

According to the output of dpkg -S, numpy has been installed using apt to remove it run:

sudo apt remove python-numpy

you might have a local installation of it using pip, to remve that you can use:

pip uninstall numpy --user
Ravexina
  • 55,668
  • 25
  • 164
  • 183
4

use --isolated option.

like below:

sudo pip uninstall numpy --isolated

Kevin Bowen
  • 19,615
  • 55
  • 79
  • 83
4

Only this above tip helped:

sudo apt remove python3-numpy 

->

The following packages were automatically installed and are no longer required:
  libjs-jquery-ui python-matplotlib-data python3-kiwisolver
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
  python3-matplotlib python3-numpy
0 upgraded, 0 newly installed, 2 to remove and 1 not upgraded.
After this operation, 28.3 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 389330 files and directories currently installed.)
Removing python3-matplotlib (3.1.2-1ubuntu4) ...
Removing python3-numpy (1:1.17.4-5ubuntu3) ...

and then reinstalling as a user:

pip3 install numpy 
  • Although I never install python packages via apt, it seems to me this answer helps with packages installed under an old distribution. – MERose Sep 17 '23 at 11:47
1

Try running with sudo but passing the python path in the command:

sudo PYTHONPATH=/usr/bin/ pip uninstall numpy -y

I was having trouble to uninstall some packages due to a lack of permission

PermissionError: [Errno 13] Permission denied: '/usr/local/bin/runlike'

and when inserting sudo in the command, it was looking for python packages in the wrong directory.

Another tip is to make sure if you're using pip or pip3 !

To check if something is still in the machine, run

dpkg -l | grep python

And uninstall any package you see is still there using apt

sudo apt remove python-nympy
sudo apt clean && sudo apt autoremove

Hope it helps!

1

I sovled the problem by editing /usr/lib/python3/dist-packages and manually removing the two directories associated with numpy.

After that I reinstalled the packages using

pip install numpy
Jeremy
  • 2,846
0

I had the same problem. I solved it when I deleted a file to which I had given the name numpy.py.

Eliah Kagan
  • 117,780
John
  • 1
  • 2
    "I solved it when I deleted a file" is really not a helpful answer to others unless you explain what file needed to be deleted along with the file path. You should consider editing your answer to make sure that it offers a solution that others can apply. – Nmath Oct 27 '20 at 00:31
0

I faced a similar problem with tartube package and it is a python package, I tried hard to remove that package but it always seems like it is not found, but I finally find a perfect solution and I hope it will be useful for you.

  1. First I searched for the package using this command:

    $ dpkg -l | grep python

  2. Then I found the python- followed by package name: Search result of python packages

    ii python3-tartube 2.3.332-1 all GUI front-end for youtube-dl

  3. Then I used the dpkg with superuser privilege to remove it using this command:

    sudo dpkg --remove python3-tartube

  • I hope this will be useful, also I want to share a picture of numpy, it's found on the pyhton package search numpy search result
Will
  • 2,292
0

I had this problem with juypter notebooks. Turns out that i had it installed globally and when i ran jupyter it was calling the global one instead of the one in the environment (or didn't instal into the venv coz it thought it was already installed, or something). So

  1. uninstalling it outside the the venv
  2. activate the venv and installing worked for me
CpILL
  • 113