Pip upgrade in virtual environment access denied - python

(Windows 10, python 3.9.13, in command prompt as administrator) I was beginning to learn tensorflow, and followed the steps on their website. When I tried to use the command "pip install --upgrade pip" in virtual environment, it shows me the following message:
Requirement already satisfied: pip in c:\windows\system32\venv\lib\site-packages (22.0.4)
Collecting pip
Using cached pip-22.1-py3-none-any.whl (2.1 MB)
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
ERROR: Could not install packages due to an OSError: [WinError 5] Access is denied: 'C:\Users\Charles\AppData\Local\Temp\pip-uninstall-r4o_l0mr\pip.exe'
Check the permissions.

Try:
python -m pip install --upgrade pip

Related

Problem downloading (pytube) library in Python

I want to download a library from Python libraries called (pytube)
When I place the download command [pip install git + https: //github.com/pytube/pytube] in the cmd panel, the following output will come out:
Collecting git+https://github.com/pytube/pytube
Cloning https://github.com/pytube/pytube to c:\users\jit\appdata\local\temp\pip-req-build-w3q3fwqn
Requirement already satisfied (use --upgrade to upgrade): pytube==10.6.1 from git+https://github.com/pytube/pytube in c:\users\jit\appdata\local\programs\python\python39\lib\site-packages
Using legacy 'setup.py install' for pytube, since package 'wheel' is not installed.
WARNING: You are using pip version 20.2.3; however, version 21.0.1 is available.
You should consider upgrading via the 'c:\users\jit\appdata\local\programs\python\python39\python.exe -m pip install --upgrade pip' command.
So I write what prompts [pip install --upgrade pip] into the cmd panel, and it gets the following output:
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\\jit\\AppData\\Local\\Temp\\pip-uninstall-pnqylmmj\\pip.exe'
Consider using the `--user` option or check the permissions.
Illustrative image :
https://suar.me/ve9J0
And in another attempt to install it, I typed the command in the (Terminal) inside the (PyCharm) program:
Collecting git+https://github.com/pytube/pytube
Cloning https://github.com/pytube/pytube to c:\users\jit\appdata\local\temp\pip-req-build-o5uke_cl
Running command git clone -q https://github.com/pytube/pytube 'C:\Users\jit\AppData\Local\Temp\pip-req-build-o5uke_cl'
Illustrative image :
https://suar.me/OZYPG
And I did not succeed in installing the library! Why is that? How do I get to the solution?
Try installing pytube3. pip install pytube3
for the pip warning it's just a warning because you are not using the latest version , use this command to upgrade it: python -m pip install --upgrade pip
Welcome to Stackoverflow!!!
For pytube as you already installed, try upgrade to latest version pytube-10.6.1:
python -m pip install --upgrade pytube
For pip install --upgrade pip error, this is happening due to insufficient access:
ERROR: Could not install packages due to an EnvironmentError: [WinError 5] Access is denied: 'C:\\Users\\jit\\AppData\\Local\\Temp\\pip-uninstall-pnqylmmj\\pip.exe'
Solution:
Consider using the `--user` option or check the permissions.
Try:
python -m pip install --upgrade pip --user
Or open the command prompt as administrator and execute the same command.

Pip says it installs mysqlclient successfully, but cannot find it or uninstall it

I am running into the following issue trying to install mysqlclient as part of getting a Django project up and running on an AWS EC2 instance.
In a python 3.8.5 virtual environment:
(venv3)$ which pip
~/venv3/bin/pip
(venv3)$ pip --version
pip 21.0.1 from /home/ec2-user/venv3/local/lib/python3.8/dist-packages/pip (python 3.8)
(venv3)$ pip install mysqlclient
Collecting mysqlclient
Using cached mysqlclient-2.0.3-cp38-cp38-linux_x86_64.whl
Installing collected packages: mysqlclient
Successfully installed mysqlclient-2.0.3
I try running the Django Shell:
(venv3)$ python manage.py shell
...full trace stack truncated for brevity...
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.
Did you install mysqlclient?
So I tried to find where pip installed it, and it seems to not actually be installed or be a trace of it anywhere:
(venv3)$ pip show mysqlclient
WARNING: Package(s) not found: mysqlclient
(venv3)$ pip freeze | grep -i mysqlclient
<nothing>
(venv3)$ sudo find / -name mysqlclient
<nothing>
Then as a sanity check I apparently successfully install it but then pip can't find it to uninstall it:
(venv3)$ pip install mysqlclient
Collecting mysqlclient
Using cached mysqlclient-2.0.3-cp38-cp38-linux_x86_64.whl
Installing collected packages: mysqlclient
Successfully installed mysqlclient-2.0.3
(venv3)$ pip uninstall mysqlclient
WARNING: Package(s) not found: mysqlclient
Other things I have tried/verified
Making sure python is the 64-bit version
Checking pip outside of the virtual environment
Nuking the virtual environment and starting again
Trying to install specific versions of mysqlclient
Installing and importing/using any other python package
EDIT: Wanted to add that I have also deleted the pip cache and it still does not work.
Answering my own question because I finally figured it out.
As per #user202729's comment I ran pip in verbose mode pip install mysqlclient --verbose which didn't itself show anything out of the ordinary as far as I could tell, but did show that mysqlclient and MySQLdb related files were being installed in /dist-packages which was not being picked my by my python installation. I copied the MySQLdb directory from venv3/lib64/python3.8/dist-packages to venv3/lib64/python3.8/site-packages and that solved the python and django issues.

Python 3 is not upgrading pip. Am I linking a wrong directory?

I have the following issue every time I try to install a package in Python 3:
WARNING: You are using pip version 20.2.4; however, version 20.3.1 is available.
You should consider upgrading via the '/usr/bin/python3 -m pip install --upgrade pip' command
I tried to do the upgrade pip command as follows, with the also following warning:
$ pip3 install --upgrade pip
Collecting pip
Using cached pip-20.3.1-py2.py3-none-any.whl (1.5 MB)
Installing collected packages: pip
Successfully installed pip-20.3.1
WARNING: You are using pip version 20.2.4; however, version 20.3.1 is available.
You should consider upgrading via the '/usr/bin/python3 -m pip install --upgrade pip' command
I tried the other way, with the same error:
$ /usr/bin/python3 -m pip install --upgrade pip
Collecting pip
Using cached pip-20.3.1-py2.py3-none-any.whl (1.5 MB)
Installing collected packages: pip
Successfully installed pip-20.3.1
WARNING: You are using pip version 20.2.4; however, version 20.3.1 is available.
You should consider upgrading via the '/usr/bin/python3 -m pip install --upgrade pip' command
I also tried the Following suggestion to solve this problem, downloading the package and ask pip to install directly from the .tar.gz file:
$sudo python3 -m pip install /home/me/Downloads/pip-20.3.1.tar.gz
[sudo] password for me:
Processing /home/me/Downloads/pip-20.3.1.tar.gz
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... done
Building wheels for collected packages: pip
Building wheel for pip (PEP 517) ... done
Created wheel for pip: filename=pip-20.3.1-py2.py3-none-any.whl size=1518515 sha256=36207044a2b9042728f3cd0f971569217f4e2e9c68c84adbf5c42617e08b9d3c
Stored in directory: /root/.cache/pip/wheels/0e/09/b2/4673e6d2eee911dbbeaeeba8e68eebb9719b1b3ba25ad93e2c
Successfully built pip
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 20.0.2
Not uninstalling pip at /usr/lib/python3/dist-packages, outside environment /usr
Can't uninstall 'pip'. No files were found to uninstall.
Successfully installed pip-20.3.1
Again, the same error happens:
$pip3 install pydot
Collecting pydot
Using cached pydot-1.4.1-py2.py3-none-any.whl (19 kB)
Collecting pyparsing>=2.1.4
Using cached pyparsing-2.4.7-py2.py3-none-any.whl (67 kB)
Installing collected packages: pyparsing, pydot
Successfully installed pydot-1.4.1 pyparsing-2.4.7
WARNING: You are using pip version 20.2.4; however, version 20.3.1 is available.
You should consider upgrading via the '/usr/bin/python3 -m pip install --upgrade pip' command.
My Python versions are:
$python --version
Python 3.7.9
$python3 --version
Python 3.8.5
My PATH variable links the following directories:
$echo $PATH
/home/me/.local/bin:/home/me/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
What is happening here? should I have to add something to my PATH variable in order to link the right python version to the pip upgrade command? or there is something else to be done?
Just do the pip3 upgrade with sudo. I think you mixed up python2 and python3 installs with your sudo call.
Just tested and gave me the correct version on pip3:
$ sudo pip3 install --upgrade pip
Collecting pip
Downloading pip-20.3.1-py2.py3-none-any.whl (1.5 MB)
|████████████████████████████████| 1.5 MB 2.6 MB/s
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 20.0.2
Not uninstalling pip at /usr/lib/python3/dist-packages, outside environment /usr
Can't uninstall 'pip'. No files were found to uninstall.
Successfully installed pip-20.3.1
$ pip3 --version
pip 20.3.1 from /usr/local/lib/python3.8/dist-packages/pip (python 3.8)
Tested on KDE Neon (Ubuntu 20.04).
Also make sure you don't have another version of pip installed somewhere in the user installations. These easily get mixed up between apt and the user locations for python installs.
pip install --upgrade pip --no-cache-dir
This worked for me
You are using pip version 19.2.3, however version 20.3.4 is available.
You should consider upgrading via the pip install --upgrade pip command.

How to update pip to latest version 20.0.2

While using this command
"python -m pip install --upgrade pip"
I get this error message:
"Collecting pip
Using cached https://files.pythonhosted.org/packages/54/0c/d01aa759fdc501a58f431eb594a17495f15b88da142ce14b5845662c13f3/pip-20.0.2-py2.py3-none-any.whl
Installing collected packages: pip
Found existing installation: pip 19.2.3
Uninstalling pip-19.2.3:
ERROR: Could not install packages due to an EnvironmentError: [WinError 5] Access is denied: 'c:\\program files (x86)\\python38-32\\lib\\site-packages\\pip-19.2.3.dist-info\\entry_points.txt'
Consider using the `--user` option or check the permissions.
WARNING: You are using pip version 19.2.3, however version 20.0.2 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command."
What's the solution to this?
I'm not too sure what the error could be, but I suspect the problem is that you are not running your terminal/command prompt as an administrator. So when you are launching your terminal/command prompt just right-click and run as administrator
Or you could try using a different method of updating pip,
pip install --upgrade pip
Can you try with this command instead ? Also if any issue persists try running cmd as Administrator
python -m pip install --user --upgrade pip

How to upgrade pip?

I want to install tensorflow, but I need to upgrade pip. How to upgrade pip? I tried to upgrade through the command line and this is what I got.
C:\Users\garoo>python -m pip install --upgrade pip
Collecting pip
Using cached https://files.pythonhosted.org/packages/d8/f3/413bab4ff08e1fc4828dfc59996d721917df8e8583ea85385d51125dceff/pip-19.0.3-py2.py3-none-any.whl
Installing collected packages: pip
Found existing installation: pip 10.0.1
Uninstalling pip-10.0.1:
Could not install packages due to an EnvironmentError: [WinError 5] Access is denied: 'c:\\program files (x86)\\python36-32\\lib\\site-packages\\pip-10.0.1.dist-info\\entry_points.txt'
Consider using the `--user` option or check the permissions.
You are using pip version 10.0.1, however version 19.0.3 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
C:\Users\garoo>python -m pip install --upgrade pip
To upgrade pip from the command line:
python -m pip install --upgrade pip
You do not need to upgrade pip to install tensorflow. Although if you still wish to do so you can try this
pip install --user --upgrade pip
Else try running the CMD as Admin
For permission error while installing Python dependencies, you need to run the terminal or command prompt or powershell as administrator
Example below:
How to upgrade pip using command prompt:
Open the command prompt from the Start Menu
Click the lower-left Start button to open the Start Menu
input cmd in the empty box and tap Command Prompt in the results
Use python -m pip install --upgrade pip to uninstall the old pip package and install the current version.
Collecting pip
Downloading pip-22.0.4-py3-none-any.whl (2.1 MB)
---------------------------------------- 2.1/2.1 MB 284.1 kB/s eta 0:00:00
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 22.0.3
Uninstalling pip-22.0.3:
Successfully uninstalled pip-22.0.3
Successfully installed pip-22.0.4
Adding up to #Iain Hunter's answer, if the command prompt provides you with an error:
'python' is not recognized as an internal or external command,
operable program or batch file.
Try changing python -m pip install --upgrade pip to py -m pip install --upgrade pip. If cmd still provides you the error, try downloading Python once again; Maybe you accidentally unchecked the download pip box while downloading Python.
m pip install --upgrade pip
Write this clause on terminal and press Enter
m pip install --upgrade pip

Categories

Resources