简体   繁体   中英

python, conda: ERROR: Could not install packages due to an OSError: [WinError 5] Access is denied: 'd:\\anaconda3\\envs\\python39\\scripts\\pip.exe'

I have tried to install requirements.txt using pip install -r requirements.txt . I always get this error:

  Using cached ansicon-1.89.0-py2.py3-none-any.whl (63 kB)
Installing collected packages: ansicon, wcwidth, six, jinxed, urllib3, readchar, python-editor, python-dateutil, jmespath, idna, chardet, certifi, blessed, requests, pyyaml, pip, mypy-extensions, inquirer, click, botocore, attrs, rollbar, redis, chalice
  Attempting uninstall: pip
    Found existing installation: pip 21.3.1
    Uninstalling pip-21.3.1:
ERROR: Could not install packages due to an OSError: [WinError 5] Access is denied: 'd:\\anaconda3\\envs\\python39\\scripts\\pip.exe'
Consider using the `--user` option or check the permissions.

Note that I am using windows 10 as OS.

I find out that the process of installation "removes my pip script" from Scripts, that is why I run pip install -r requirements.txt --user I got

Cannot open D:\anaconda3\envs\python39\Scripts\pip-script.py

I have also tried to upgrade pip but could not

Cannot open D:\anaconda3\envs\python39\Scripts\pip-script.py

For those who may say try to install pip via conda first I am getting:

$ conda install pip
Collecting package metadata (current_repodata.json): done
Solving environment: done


==> WARNING: A newer version of conda exists. <==
  current version: 4.10.1
  latest version: 4.10.3

Please update conda by running

    $ conda update -n base -c defaults conda     



# All requested packages already installed.

I have run the command as administrator, I have tried many versions of python within conda . I have also installed python globally (once I restart my system the global python folder vanish). I have also tried to install the requirements file with conda but it does not find the chalice and rollbar in conda or conda forge channel.

This is my requirements.txt

chalice==1.23.0
requests==2.25.1
rollbar==0.15.2
redis==3.5.3

How could I fix this?

For the missing script due to installation, use this: python -m ensurepip --default-pip For more, you can check this You can also check this issue on GitHub here

What is ensurepip and when to use it?

ensurepip is a package that supports bootstrapping for pip . It is used when for some reason installing pip was skipped. From the doc:

In most cases, end users of Python shouldn't need to invoke this module directly (as pip should be bootstrapped by default), but it may be needed if installing pip was skipped when installing Python (or when creating a virtual environment) or after explicitly uninstalling pip. check out ensurepip doc

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM