Unable to upgrade pip using pip install --upgrade pip [duplicate] - pip

This question already has answers here:
Python - PIP install trouble shooting - PermissionError: [WinError 5] Access is denied
(20 answers)
Access is denied when trying to pip install a package on Windows
(9 answers)
Closed 1 year ago.
I wanted to upgrade pip for installing libraries to learn machine learning. But i am unable to do so.
C:\Users\adith>pip install --upgrade pip
Collecting pip
Downloading pip-21.0.1-py3-none-any.whl (1.5 MB)
|████████████████████████████████| 1.5 MB 211 kB/s
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 20.2.3
Uninstalling pip-20.2.3:
Successfully uninstalled pip-20.2.3
ERROR: Could not install packages due to an EnvironmentError: [WinError 5] Access is denied: 'C:\\Users\\adith\\AppData\\Local\\Temp\\pip-uninstall-40mydp3z\\pip.exe'
Consider using the `--user` option or check the permissions.
I am getting the above error. Any help would be very much appreciated. Thanks!

There are two ways to go about this:
* (Recommended way) is to just append the --user flag to the command you are trying to run, so you would run pip install --upgrade pip --user
or
* open cmd as an administrator and run that command
..................................................................................................................................
The reason this happened is because the folder you are trying to install pip is a folder that requires admin privileges to access.
Next time you should pay attention to what the error message says.
Most of the time the error message is self explanitory and there is no need to post a new question on S.O.

Related

Can't install spacy for NLP tasks

I'm trying to install spaCy for NLP tasks but when I follow the first instruction from https://spacy.io/usage (pip install -U pip setuptools wheel) I get the error below. I believe my error may come from me creating two different users for my laptop, my lack of understanding of environment variables, virtual environments, and my path variable. I also do not understand the message about no metadata being found.
Microsoft Windows [Version 10.0.19043.1706]
(c) Microsoft Corporation. All rights reserved.
C:\Python310\Scripts>pip install -U pip setuptools wheel
Requirement already satisfied: pip in c:\users\user\appdata\roaming\python\python310\site-packages (22.0.4)
Collecting pip
Using cached pip-22.1.2-py3-none-any.whl (2.1 MB)
Requirement already satisfied: setuptools in c:\python310\lib\site-packages (62.3.2)
Requirement already satisfied: wheel in c:\python310\lib\site-packages (0.37.1)
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 22.0.4
Uninstalling pip-22.0.4:
Successfully uninstalled pip-22.0.4
WARNING: No metadata found in c:\users\user\appdata\roaming\python\python310\site-packages
Rolling back uninstall of pip
Moving to c:\users\user\appdata\roaming\python\python310\scripts\pip.exe
from C:\Users\User\AppData\Local\Temp\pip-uninstall-on_65qs2\pip.exe
Moving to c:\users\user\appdata\roaming\python\python310\scripts\pip3.10.exe
from C:\Users\User\AppData\Local\Temp\pip-uninstall-on_65qs2\pip3.10.exe
Moving to c:\users\user\appdata\roaming\python\python310\scripts\pip3.exe
from C:\Users\User\AppData\Local\Temp\pip-uninstall-on_65qs2\pip3.exe
Moving to c:\users\user\appdata\roaming\python\python310\site-packages\pip-22.0.4.dist-info\
from C:\Users\User\AppData\Roaming\Python\Python310\site-packages\~ip-22.0.4.dist-info
Moving to c:\users\user\appdata\roaming\python\python310\site-packages\pip\
from C:\Users\User\AppData\Roaming\Python\Python310\site-packages\~ip
ERROR: Could not install packages due to an OSError: [WinError 5] Access is denied: 'C:\\Python310\\Lib\\site-packages\\pip\\__init__.py'
Consider using the `--user` option or check the permissions.
WARNING: You are using pip version 22.0.4; however, version 22.1.2 is available.
You should consider upgrading via the 'C:\Python310\python.exe -m pip install --upgrade pip' command.
C:\Python310\Scripts>
Screenshot of error message

Error when pip install tensorflowjs — Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory:

An error happens while installing tensorflowjs, it's ok to install other packages, just this package ends up with failure.
I tried to pip install --user pyspider, failed.
I upgraded pip version, still failed.
I installed tf_nightly module first and run 'pip install tensorflowjs', still failed.
C:\Users\Jingyi>pip install tensorflowjs
Collecting tensorflowjs
Using cached https://files.pythonhosted.org/packages/79/29/35e1aa467436ff46b98df65a08c49faaedb3429e1c512d1d90fe308040a0/tensorflowjs-1.0.1-py3-none-any.whl
Collecting numpy==1.15.1 (from tensorflowjs)
Using cached https://files.pythonhosted.org/packages/fb/7d/f8b97d97809f184d90faf320fa8e2e7eac994844c5e6c57adbed1283e9e9/numpy-1.15.1-cp36-none-win_amd64.whl
Collecting six==1.11.0 (from tensorflowjs)
Using cached https://files.pythonhosted.org/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl
Collecting tf-nightly-2.0-preview>=2.0.0.dev20190304 (from tensorflowjs)
Using cached https://files.pythonhosted.org/packages/4c/13/8fa7c91176d299759487d90ab201256941b43a48ecbf033a2a726f4dafce/tf_nightly_2.0_preview-2.0.0.dev20190509-cp36-cp36m-win_amd64.whl
ERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: 'C:\\Users\\Jingyi\\AppData\\Local\\Temp\\pip-install-4ytziwpr\\tf-nightly-2.0-preview\\tf_nightly_2.0_preview-2.0.0.dev20190509.data/purelib/tensorflow/include/tensorflow/include/external/eigen_archive/unsupported/Eigen/CXX11/src/Tensor/TensorSyclConvertToDeviceExpression.h'
I expect to install tensorflowjs successfully.
It was caused by windows path length limitation, you can try below:
Hit the Windows key, type gpedit.msc and press Enter.
Navigate to Local Computer Policy > Computer Configuration > Administrative Templates > System > Filesystem.
Double click the Enable Win32 long paths option and enable it.
Then restart computer and it works
Original answer here
You can create a virtualenv and install tensorflow within this.
First create a virtualenv:
python3 -m venv envname
Next you have to activate it
source envname/bin/activate
Then install the package
pip install pyspider
When you use a virtualenv you don't nedd the --user flag.
Using a virtualenv is always a better way when you are working locally with python projects.

Has virtualenv installed correctly when `pip install virtualenv` outputs `using cached virtualenv`?

Context: Am working on the flaskr web project on Mac OS High Sierra.
Am at stage of installing Flask and I am running into issues with installing virtualenv: http://flask.pocoo.org/docs/0.12/tutorial/packaging/
When running the following line in Terminal:
pip install virtualenv
I get:
pip install virtualenv
Collecting virtualenv
Using cached virtualenv-15.2.0-py2.py3-none-any.whl
matplotlib 1.3.1 requires nose, which is not installed.
matplotlib 1.3.1 requires tornado, which is not installed.
matplotlib 1.3.1 has requirement numpy>=1.5, but you'll have numpy
1.8.0rc1 which is incompatible.
Installing collected packages: virtualenv
I was expecting a response 'successfully installed virtualenv...' as appears in this video: https://youtu.be/-COGZITgHtw?t=1m9s.
Then, when running the following in Terminal:
virtualenv
I get:
-bash: virtualenv: command not found
I note others have had issues with ‘command not found’ (bash: pip: command not found, How to add virtualenv to path) but I cannot seem to find outputs which mirror what I have received.
Is the cached virtualenv holding things up? Or perhaps the matplotlib stuff? Either way, virtualenv doesn't appear to have installed as it ought.
Would it be wise (in any case) to update or install nose, tornado and numpy using pip so that I can progress to activating a virtualenv? Or is something I need to address first before I can get virtuanlenv to start working?
I did the same error, but succeeded with the following procedure.
$ brew install python3
$ pip3 install --upgrade virtualenv
Collecting virtualenv
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Downloading virtualenv-15.2.0-py2.py3-none-any.whl (2.6MB)
100% |████████████████████████████████| 2.6MB 226kB/s
Installing collected packages: virtualenv
Successfully installed virtualenv-15.2.0

Installing Tensorflow with Python 3.5 and Anaconda

I have Anaconda 3.19.3 with Python 3.5 on a Mac. Now, I would like to install TensorFlow via pip. The installation instructions here also include setup instructions for installing TensorFlow under Python 3.3+.
So, I have executed sudo easy_install --upgrade six, no problem. When I execute sudo pip3 install --upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.7.0-py3-none-any.whl, after downloading the necessary packages, I get the following:
Installing collected packages: setuptools, protobuf, tensorflow
Found existing installation: setuptools 19.6.2
Uninstalling setuptools-19.6.2:
Successfully uninstalled setuptools-19.6.2
Rolling back uninstall of setuptools
Exception:
...
AttributeError: _ep_map
During handling of the above exception, another exception occurred:
...
FileNotFoundError: [Errno 2] No such file or directory: '/Users/me/anaconda/lib/python3.5/site-packages/setuptools-19.6.2-py3.5.egg'
I have left out some of the error message to save space.
What is this and, more importantly, what can I do about it?
See the answer here:
Error setuptools when installing tensorflow
In particular, you could try adding the --ignore-installed tag to the end of your pip command.

Cannot install pip for python3 on mac

When I run
curl -O https://raw.github.com/pypa/pip/master/contrib/get-pip.py
sudo python3 get-pip.py
It gives me this error:
Downloading/unpacking pip
Cannot fetch index base URL https://pypi.python.org/simple/
Could not find any downloads that satisfy the requirement pip
Cleaning up...
No distributions at all found for pip
Storing debug log for failure in /var/root/.pip/pip.log
However if I just run:
sudo python get-pip.py
There is no problem:
Downloading/unpacking pip from https://pypi.python.org/packages/py2.py3/p/pip/pip-1.5.2-py2.py3-none-any.whl#md5=445a893564065937c0f31ac2cc8e2f35
Downloading pip-1.5.2-py2.py3-none-any.whl (1.2MB): 1.2MB downloaded
Installing collected packages: pip
Found existing installation: pip 1.5.1
Uninstalling pip:
Successfully uninstalled pip
Successfully installed pip
Cleaning up...
Can anyone help please? Thanks!
This is a simple permissions issue. If you're installing to the system Python installation, you should need root, which is what sudo provides.
If you need to install stuff where you don't have root privileges, you need to look into Python virtual environments.

Resources