Cannot uninstall numpy, - python

I'm trying to use pip to uninstall numpy(I also installed pandas, but I seem to have been able to uninstall that). In the case of `numpy, I get the following output.
pip3 uninstall numpy -vvv --log pip.txt
Uninstalling numpy-1.12.1:
/usr/lib64/python3.6/site-packages/numpy
/usr/lib64/python3.6/site-packages/numpy-1.12.1-py3.6.egg-info
Removing file or directory /usr/lib64/python3.6/site-packages/numpy
Exception:
Traceback (most recent call last):
File "/usr/lib64/python3.6/shutil.py", line 544, in move
os.rename(src, real_dst)
OSError: [Errno 18] Invalid cross-device link: '/usr/lib64/python3.6/site-packages/numpy' -> '/tmp/pip-odkg0wo0-uninstall/usr/lib64/python3.6/site-packages/numpy'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/lib/python3.6/site-packages/pip/commands/uninstall.py", line 76, in run
requirement_set.uninstall(auto_confirm=options.yes)
File "/usr/lib/python3.6/site-packages/pip/req/req_set.py", line 346, in uninstall
req.uninstall(auto_confirm=auto_confirm)
File "/usr/lib/python3.6/site-packages/pip/req/req_install.py", line 754, in uninstall
paths_to_remove.remove(auto_confirm)
File "/usr/lib/python3.6/site-packages/pip/req/req_uninstall.py", line 115, in remove
renames(path, new_path)
File "/usr/lib/python3.6/site-packages/pip/utils/__init__.py", line 267, in renames
shutil.move(old, new)
File "/usr/lib64/python3.6/shutil.py", line 556, in move
rmtree(src)
File "/usr/lib64/python3.6/shutil.py", line 480, in rmtree
_rmtree_safe_fd(fd, path, onerror)
File "/usr/lib64/python3.6/shutil.py", line 418, in _rmtree_safe_fd
_rmtree_safe_fd(dirfd, fullname, onerror)
File "/usr/lib64/python3.6/shutil.py", line 438, in _rmtree_safe_fd
onerror(os.unlink, fullname, sys.exc_info())
File "/usr/lib64/python3.6/shutil.py", line 436, in _rmtree_safe_fd
os.unlink(name, dir_fd=topfd)
PermissionError: [Errno 13] Permission denied: 'multiarray_tests.cpython-36m-x86_64-linux-gnu.so'
I've got a Fedora 26 system running both Python 2.7.15 and Python 3.6.5
I'm very new to Python (just started learning it last night), so forgive the ignorance. I've seen several related questions (mostly dealing with pip installs rather than uninstalls. None of them seemed to solve the issue. I should also note that I've read in these other posts that running pip as sudo is a bad idea (something I did while trying to install pandas because I didn't have permissions (and again, I read later on that that is a bad idea). Any help here is appreciated.

For python3:
sudo pip3 uninstall numpy
For python:
sudo pip uninstall numpy
or using:
sudo apt-get remove python-numpy

I had a similar problem with numpy and I just had to remove the package using apt (In your case is yum).
Try to do:
sudo yum remove python3-numpy

Try running it with root authorization
sudo pip3 uninstall numpy
It should work, most of the times.

in your case
sudo apt remove python-numpy
and
sudo pip install numpy==[Version you need]

Related

Installing Pandas on MacOs. Permission Error

I am trying to pip install pandas on a mac. I have python 3.6 installed.
When I pip install in the terminal I get the following error:
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py", line 342, in run
prefix=options.prefix_path,
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py", line 784, in install
**kwargs
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 851, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 1064, in move_wheel_files
isolated=self.isolated,
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/wheel.py", line 345, in move_wheel_files
clobber(source, lib_dir, True)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/wheel.py", line 316, in clobber
ensure_dir(destdir)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/utils/__init__.py", line 83, in ensure_dir
os.makedirs(path)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/pandas'
Could you possibly edit the error into a formatted code block by highlighting it and pushing ctrl+k so it is easier to read? Thanks.
Edit: Also, I just looked through and at the bottom it says permission denied. Try rerunning the command as an admin. I.E try this command:
sudo pip install pandas
You might have already noticed, Mac come with a built in Python, python 2.7. If you read your traceback: /Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py it's pointing to the 2.7 dir. this dir is in the Library folder so you don't have permission to install to it.
But you state that you have Python 3.6 installed as well, so if you wanted to install to that indtead. Do pip3 install pandas or python3 -m pip install pandas this help specify the python version. And if you want to run python 3.6 in terminal, type python3 instead of just python

Conda Update fails with PermissionError

I'm on Mac OS 10.9 and running Python 3.5.2
I tried updating conda
conda update conda
but it gave me this error
Traceback (most recent call last):
File "/Users/cd/anaconda3/bin/conda", line 6, in <module>
sys.exit(main())
File "/Users/cd/anaconda3/lib/python3.5/site-packages/conda/cli/main.py", line 139, in main
File "/Users/cd/anaconda3/lib/python3.5/site-packages/conda/cli/main.py", line 146, in args_func
File "/Users/cd/anaconda3/lib/python3.5/site-packages/conda/cli/main_update.py", line 64, in execute
File "/Users/cd/anaconda3/lib/python3.5/site-packages/conda/cli/install.py", line 424, in install
File "/Users/cd/anaconda3/lib/python3.5/site-packages/conda/plan.py", line 539, in execute_actions
File "/Users/cd/anaconda3/lib/python3.5/site-packages/conda/instructions.py", line 149, in execute_instructions
File "/Users/cd/anaconda3/lib/python3.5/site-packages/conda/instructions.py", line 92, in LINK_CMD
File "/Users/cd/anaconda3/lib/python3.5/site-packages/conda/instructions.py", line 88, in link
File "/Users/cd/anaconda3/lib/python3.5/site-packages/conda/install.py", line 634, in link
File "/Users/cd/anaconda3/lib/python3.5/os.py", line 241, in makedirs
mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/Users/cd/anaconda3/etc/fish/conf.d’
I searched around and thought the problem was that I needed to chown the folder with my user (which is 'cd' in my case):
sudo chown -R cd anaconda3
Then I tried conda update conda, but now it gives a different error:
zsh: /Users/cd/anaconda3/bin/conda: bad interpreter: /opt/anaconda1anaconda2anaconda3/bin/python3: no such file or directory
I tried putting chownback to root:
sudo chown -R root anaconda3
but when I tried conda update conda it gave me the same "bad interpreter" error.
where conda gives /Users/cd/anaconda3/bin/conda
I don't know if the problem was the chowncommand or not, but please let me know if you need any more details!
Your shebang line in /Users/USER/anaconda/bin/conda is broken:
#!/opt/anaconda1anaconda2anaconda3/bin/python
just switch it back to point to the link of your install of Anaconda:
#!/Users/USER/anaconda/bin/python

Cannot pip install anything with OS X El Capitan

I am trying to pip install virtualenv (and anything else) on OS X El Capitan and got the following error:
Exception:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/pip/basecommand.py", line 211, in main
status = self.run(options, args)
File "/usr/local/lib/python2.7/site-packages/pip/commands/install.py", line 311, in run
root=options.root_path,
File "/usr/local/lib/python2.7/site-packages/pip/req/req_set.py", line 646, in install
**kwargs
File "/usr/local/lib/python2.7/site-packages/pip/req/req_install.py", line 803, in install
self.move_wheel_files(self.source_dir, root=root)
File "/usr/local/lib/python2.7/site-packages/pip/req/req_install.py", line 998, in move_wheel_files
isolated=self.isolated,
File "/usr/local/lib/python2.7/site-packages/pip/wheel.py", line 339, in move_wheel_files
clobber(source, lib_dir, True)
File "/usr/local/lib/python2.7/site-packages/pip/wheel.py", line 282, in clobber
ensure_dir(dest) # common for the 'include' path
File "/usr/local/lib/python2.7/site-packages/pip/utils/__init__.py", line 71, in ensure_dir
os.makedirs(path)
File "/usr/lib/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 1] Operation not permitted: '/usr/lib/python2.7/site-packages'
Looks pip is trying to write in '/usr/lib/python2.7/site-packages' and due to SIP in El Capitan it got denied.
But I was wondering why does pip needs to write there? How can I fix this?
I ran brew doctor
which gives
Your system is ready to brew.
So I think it is OK.
I tried brew reinstall python and it gives an odd error:
==> Reinstalling python
Error: /usr/local/opt/python is not a valid keg
which python gives
/usr/local/bin/python
So where in system has this weird thing that let pip fail
Update:
It looks my pip is pointing to system python rather than brewed python.
I changed the first line of pip to
#!/usr/local/bin/python
and problem is solved
You may need to brew link python, or unlink then link to get things pointing to the correct places.

How to install OpenCV for Python 3.x on Windows 8.1?

I am trying to install and run OpenCV 3.0.0 for python 3.4.2, in Windows 8.1.
I have downloaded the OpenCV file from http://opencv.org/.
Extracted the folder in C:.
I went to System → Advanced System Settings → Advanced → Environment variables
Add a new variable in "User Variables frame". Name it "OPENCV_DIR" with value "c:\opencv\build\x64\vc12".
Add this at the end of Path: ";C:\opencv;C:\opencv\build;%OPENCV_DIR%\bin"
I took the archive "cv2.pyd" from "C:\opencv\build\python\2.7\x64" and copied it.
I pasted it in C:\Python34\Lib\site-packages.
Finally I went to the IDLE of Python 3.4.2 and wrote (this happened before copying the fine into the Python directory):
import cv2
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import cv2
ImportError: No module named 'cv2'
And this happened after I copied the file into the Python directory:
import cv2
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
import cv2
ImportError: DLL load failed: The specified module could not be found.
What am I doing wrong? I not sure whether I should install CMake and NumPy.
Also I am not sure how to use this webpage (recommended by so many people),
http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv, where many Python libraries are available, including PIL, OpenCV, VideoCapture, etc...
I want to try to run the examples from:
Face Detection in Python Using a Webcam
1: Introduction to Python and OpenCV
Face Detection With OS X and Python
OK, I should not use the file from Python 2.7 in Python 3.4. It won't work. I deleted it, so as otterb suggested, I just installed the opencv_python‑3.0.0‑cp34‑none‑win_amd64.whl package from http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv, but this file is an .whl not an EXE file, and according to How do I install a Python package with a .whl file? I followed these steps:
Go to the command prompt
Change directory with "cd" to where I downloaded the file
And write "pip install opencv_python-3.0.0-cp34-none-win_amd64.whl"
But I got the following message in red:
Installing collected packages: opencv-python
Cleaning up...
Exception:
Traceback (most recent call last):
File "C:\Python34\lib\shutil.py", line 370, in _rmtree_unsafe
os.unlink(fullname)
PermissionError: [WinError 32] The process cannot access the file because it is
being used by another process: 'C:\\Users\\JOSEFG~1\\AppData\\Local\\Temp\\pip-n
kyo0c6u-build\\opencv_python-3.0.0.data\\data\\Lib\\site-packages\\cv2.pyd'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\pip\commands\install.py", line 283, in run
requirement_set.install(install_options, global_options, root=options.root_p
ath)
File "C:\Python34\lib\site-packages\pip\req.py", line 1444, in install
requirement.remove_temporary_source()
File "C:\Python34\lib\site-packages\pip\req.py", line 761, in remove_temporary
_source
rmtree(self._temp_build_dir)
File "C:\Python34\lib\site-packages\pip\util.py", line 43, in rmtree
onerror=rmtree_errorhandler)
File "C:\Python34\lib\shutil.py", line 477, in rmtree
return _rmtree_unsafe(path, onerror)
File "C:\Python34\lib\shutil.py", line 367, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "C:\Python34\lib\shutil.py", line 367, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "C:\Python34\lib\shutil.py", line 367, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "C:\Python34\lib\shutil.py", line 367, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "C:\Python34\lib\shutil.py", line 372, in _rmtree_unsafe
onerror(os.unlink, fullname, sys.exc_info())
File "C:\Python34\lib\site-packages\pip\util.py", line 53, in rmtree_errorhandler
(exctype is PermissionError and value.args[3] == 5) #python3.3
IndexError: tuple index out of range
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Python34\lib\shutil.py", line 370, in _rmtree_unsafe
os.unlink(fullname)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\JOSEFG~1\\AppData\\Local\\Temp\\pip-nkyo0c6u-build\\opencv_python-3.0.0.data\\data\\Lib\\site-packages\\cv2.pyd'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\pip\basecommand.py", line 122, in main
status = self.run(options, args)
File "C:\Python34\lib\site-packages\pip\commands\install.py", line 302, in run
requirement_set.cleanup_files(bundle=self.bundle)
File "C:\Python34\lib\site-packages\pip\req.py", line 1319, in cleanup_files
req.remove_temporary_source()
File "C:\Python34\lib\site-packages\pip\req.py", line 761, in remove_temporary_source
rmtree(self._temp_build_dir)
File "C:\Python34\lib\site-packages\pip\util.py", line 43, in rmtree
onerror=rmtree_errorhandler)
File "C:\Python34\lib\shutil.py", line 477, in rmtree
return _rmtree_unsafe(path, onerror)
File "C:\Python34\lib\shutil.py", line 367, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "C:\Python34\lib\shutil.py", line 367, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "C:\Python34\lib\shutil.py", line 367, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "C:\Python34\lib\shutil.py", line 367, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "C:\Python34\lib\shutil.py", line 372, in _rmtree_unsafe
onerror(os.unlink, fullname, sys.exc_info())
File "C:\Python34\lib\site-packages\pip\util.py", line 53, in rmtree_errorhandler
(exctype is PermissionError and value.args[3] == 5) #python3.3
IndexError: tuple index out of range
Storing debug log for failure in C:\Users\me\pip\pip.log
Which means after reading it carefully that the file is unsafe to install on my PC.
Also it seems that pip should be the latest one to run the previous command according to How do I install pip on Windows?. Then I just upgrade pip in the command prompt with
python -m pip install -U pip
Now I have version 7.1. I know it by writing:
pip --version
Then I tried again
pip install opencv_python-3.0.0-cp34-none-win_amd64.whl
But it seems that it is working as I am getting this message:
C:\Users\Jose F Gomez D\Downloads>pip install opencv_python-3.0.0-cp34-none-win_amd64.whl
Requirement already satisfied (use --upgrade to upgrade): opencv-python==3.0.0 from file:///C:/Users/Jose%20F%20Gomez%20D/Downloads/opencv_python-3.0.0-cp34-none-win_amd64.whl in c:\python34\lib\site-packages
then I write in the python shell "import cv2" but there is a new error
ImportError: numpy.core.multiarray failed to import
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import cv2
ImportError: numpy.core.multiarray failed to import
so I installed the numpy (and scipy just in case) library with
pip install numpy
pip install scipy
But it is not working as it requires C++
error microsoft visual c++ 10 is required
I tried to find "Visual C++ 2010 Express" from the webpage of Visual Studio at https://www.visualstudio.com/, but there is no link to "Microsoft Visual C++ 2010 express", so I went to page http://microsoft-visual-cpp-express.soft32.com/free-download/, downloaded the file, executed it, and now I got C++.
Again I went to the command prompt and tried to install NumPy and SciPy and it did not work. There is an error in the path:
ValueError: ['path']
OK, now I tried to install the NumPy and SciPy packages from:
http://sourceforge.net/projects/numpy/files/NumPy/
But it did not work, so I went to Gohike, http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy, and installed NumPy and SciPy from the command prompt in administrator mode:
pip install scipy‑0.16.0‑cp34‑none‑win_amd64.whl
pip install numpy‑1.9.2+mkl‑cp34‑none‑win_amd64.whl
Now I tried to run cv, but nothing. Uups, it's cv2, and it is working. I will write the answer next.
The right way to install OpenCV 3.0.0 for Python 3.4.2 on Windows 8.1:
Go to http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv
Download OpenCV, NumPy and SciPy
For me I needed:
opencv_python-3.0.0-cp34-none-win_amd64.whl
scipy‑0.16.0‑cp34‑none‑win_amd64.whl
numpy‑1.9.2+mkl‑cp34‑none‑win_amd64.whl
Download and install Visual C++ 2010 Express from http://microsoft-visual-cpp-express.soft32.com/free-download/
Open a command prompt as administrator
Change directory like "cd C:\Users\me\Downloads" to where I downloaded the file
Copy and paste this: "python -m pip install -U pip"
Then install the libraries. Copy and paste this:
pip install opencv_python-3.0.0-cp34-none-win_amd64.whl
pip install scipy‑0.16.0‑cp34‑none‑win_amd64.whl
pip install numpy‑1.9.2+mkl‑cp34‑none‑win_amd64.whl
That is all.
-------------> Tricky Python <------------
You can use pip to install the whl file like:
pip install path/to/whlfile
Yes, you are right. Gohlke's package used to be an EXE file file, but OpenCV is now distributed as whl. Sorry I missed that.
Here is a similar Stack Overflow question: How do I install a Python package with a .whl file?
I have successfully installed OpenCV 3.1.0 using conda (install Anaconda 3 - 64 bit ) with the following command (conda installation of OpenCV 3):
conda install -c menpo opencv3=3.1.0
Please note that the only complete installation is obtained compiling the OpenCV libraries from the GitHub repository. I have found that some features (e.g. SURF detection) are missing from the conda installation and also from the wheels.
I did everything as mentioned by Jose Fernando Gomez Davila except I installed numpy before scipy as numpy is required to install scipy
pip install opencv_python-4.1.2-cp37-cp37m-win_amd64.whl
pip install scipy-1.4.1-cp37-cp37m-win_amd64.whl
pip install numpy-1.16.6+mkl-cp37-cp37m-win_amd64.whl

OSError: [Errno 13] Permission denied

I am new to using command line and apologize in advance for any confusion.
I am trying to install STAMP but I get an Errno 13 Permission denied as response.
Found existing installation: scipy 0.13.0b1
DEPRECATION: Uninstalling a distutils installed project (scipy) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
Uninstalling scipy-0.13.0b1:
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip-6.1.1-py2.7.egg/pip/basecommand.py", line 246, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip-6.1.1-py2.7.egg/pip/commands/install.py", line 352, in run
root=options.root_path,
File "/Library/Python/2.7/site-packages/pip-6.1.1-py2.7.egg/pip/req/req_set.py", line 687, in install
requirement.uninstall(auto_confirm=True)
File "/Library/Python/2.7/site-packages/pip-6.1.1-py2.7.egg/pip/req/req_install.py", line 730, in uninstall
paths_to_remove.remove(auto_confirm)
File "/Library/Python/2.7/site-packages/pip-6.1.1-py2.7.egg/pip/req/req_uninstall.py", line 126, in remove
renames(path, new_path)
File "/Library/Python/2.7/site-packages/pip-6.1.1-py2.7.egg/pip/utils/__init__.py", line 292, in renames
shutil.move(old, new)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 302, in move
os.unlink(src)
OSError: [Errno 13] Permission denied: '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/scipy-0.13.0b1-py2.7.egg-info'
I know this issue has been covered in depth but I cannot figure out how to apply the answers to my specific problem.
Any ideas?
Thank you in advance
TVAN
sudo pip install STAMP
whenever you see the phrase like this:"Permission denied", you should look up for this command.

Categories

Resources