安装好anaconda以及cuda,cudnn之后,安装tensorflow,敲完命令:pip install --upgrade tensorflow-gpu出现如下错误:
PermissionError: [WinError 5]拒绝访问。
Exception:
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\shutil.py", line 544, in move
os.rename(src, real_dst)
PermissionError: [WinError 5] 拒绝访问。: 'c:\\programdata\\anaconda3\\lib\\site-packages\\pip' -> 'C:\\Users\\Administrator\\AppData\\Local\\Temp\\pip-syl6gg6l-uninstall\\programdata\\anaconda3\\lib\\site-packages\\pip'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\pip\basecommand.py", line 215, in main
status = self.run(options, args)
File "C:\ProgramData\Anaconda3\lib\site-packages\pip\commands\install.py", line 342, in run
prefix=options.prefix_path,
File "C:\ProgramData\Anaconda3\lib\site-packages\pip\req\req_set.py", line 778, in install
requirement.uninstall(auto_confirm=True)
File "C:\ProgramData\Anaconda3\lib\site-packages\pip\req\req_install.py", line 754, in uninstall
paths_to_remove.remove(auto_confirm)
File "C:\ProgramData\Anaconda3\lib\site-packages\pip\req\req_uninstall.py", line 115, in remove
renames(path, new_path)
File "C:\ProgramData\Anaconda3\lib\site-packages\pip\utils\__init__.py", line 267, in renames
shutil.move(old, new)
File "C:\ProgramData\Anaconda3\lib\shutil.py", line 556, in move
rmtree(src)
File "C:\ProgramData\Anaconda3\lib\shutil.py", line 494, in rmtree
return _rmtree_unsafe(path, onerror)
File "C:\ProgramData\Anaconda3\lib\shutil.py", line 389, in _rmtree_unsafe
onerror(os.unlink, fullname, sys.exc_info())
File "C:\ProgramData\Anaconda3\lib\shutil.py", line 387, in _rmtree_unsafe
os.unlink(fullname)
PermissionError: [WinError 5] 拒绝访问。: 'c:\\programdata\\anaconda3\\lib\\site-packages\\pip\\basecommand.py'
在网上搜了搜,发现应该是权限问题。看到有类似的错误,尝试在命令中加--user解决。
因此,将命令改成:pip install --user --upgrade tensorflow-gpu
问题解决。