pip报“PermissionError: [WinError 5] 拒绝访问。”解决方案

今天安装spacy这个NLP工具,使用环境是anaconda3,默认安装在C盘了。结果使用pip安装Spacy,出现如下提示:

Exception: Traceback (most recent call last): File "C:\Users\w\Anaconda3\lib\shutil.py", line 387, in _rmtree_unsafe os.unlink(fullname) PermissionError: [WinError 5] 拒绝访问。: 'C:\\Users\\w\\AppData\\Local\\Temp\\pip-rfrclcoc-uninstall\\users\\w\\anaconda3\\lib\\site-packages\\msgpack\\_packer.cp36-win_amd64.pyd' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users\w\Anaconda3\lib\site-packages\pip\basecommand.py", line 215, in main status = self.run(options, args) File "C:\Users\w\Anaconda3\lib\site-packages\pip\commands\install.py", line 342, in run prefix=options.prefix_path, File "C:\Users\w\Anaconda3\lib\site-packages\pip\req\req_set.py", line 795, in install requirement.commit_uninstall() File "C:\Users\w\Anaconda3\lib\site-packages\pip\req\req_install.py", line 767, in commit_uninstall self.uninstalled.commit() File "C:\Users\w\Anaconda3\lib\site-packages\pip\req\req_uninstall.py", line 142, in commit rmtree(self.save_dir) File "C:\Users\w\Anaconda3\lib\site-packages\pip\_vendor\retrying.py", line 49, in wrapped_f return Retrying(*dargs, **dkw).call(f, *args, **kw) File "C:\Users\w\Anaconda3\lib\site-packages\pip\_vendor\retrying.py", line 212, in call raise attempt.get() File "C:\Users\w\Anaconda3\lib\site-packages\pip\_vendor\retrying.py", line 247, in get six.reraise(self.value[0], self.value[1], self.value[2]) File "C:\Users\w\Anaconda3\lib\site-packages\six.py", line 686, in reraise File "C:\Users\w\Anaconda3\lib\site-packages\pip\_vendor\retrying.py", line 200, in call attempt = Attempt(fn(*args, **kwargs), attempt_number, False) File "C:\Users\w\Anaconda3\lib\site-packages\pip\utils\__init__.py", line 102, in rmtree onerror=rmtree_errorhandler) File "C:\Users\w\Anaconda3\lib\shutil.py", line 494, in rmtree return _rmtree_unsafe(path, onerror) File "C:\Users\w\Anaconda3\lib\shutil.py", line 384, in _rmtree_unsafe _rmtree_unsafe(fullname, onerror) File "C:\Users\w\Anaconda3\lib\shutil.py", line 384, in _rmtree_unsafe _rmtree_unsafe(fullname, onerror) File "C:\Users\w\Anaconda3\lib\shutil.py", line 384, in _rmtree_unsafe _rmtree_unsafe(fullname, onerror) [Previous line repeated 2 more times] File "C:\Users\w\Anaconda3\lib\shutil.py", line 389, in _rmtree_unsafe onerror(os.unlink, fullname, sys.exc_info()) File "C:\Users\w\Anaconda3\lib\site-packages\pip\utils\__init__.py", line 114, in rmtree_errorhandler func(path) PermissionError: [WinError 5] 拒绝访问。: 'C:\\Users\\w\\AppData\\Local\\Temp\\pip-rfrclcoc-uninstall\\users\\w\\anaconda3\\lib\\site-packages\\msgpack\\_packer.cp36-win_amd64.pyd'

之前安装也出现过这个拒绝访问的问题,于是百度了一下,发现开着Jupyter notebook会有一些插件例如numpy在后台运行,干扰安装。于是关闭了运行的python,再用pip,完美安装了spacy和附属语言包。

如果使用conda来安装Spacy,会出现安装不成功的情况。提示:

ERROR conda.core.link:_execute_actions(337): An error occurred while installing package 'conda-forge::tqdm-4.19.5-py_0'.

CondaError: Cannot link a source that does not exist. C:\Users\w\Anaconda3\Scripts\conda.exe

Running `conda clean --packages` may resolve your problem.

这时候就需要先升级conda的安装功能。不知道为什么,需要通过升级pip来实现

conda install pip

升级完就可以用conda安装了。

你可能感兴趣的:(pip报“PermissionError: [WinError 5] 拒绝访问。”解决方案)