安装Python库imbalance-learn package 时报错PermissionError解决方法

win10中在命令提示符(dos)中安装Python库imbalance-learn package报错,错误如下: 

使用的安装命令:pip install -U imbalanced-learn,安装时会卸载并重安装numpy、scipy、scikit-learn,报错就是报在卸载这些库上面。

报错:PermissionError: [Errno 13] Permission denied: 'D:\\software\\anaconda\\envs\\*****\\Lib\\site-packages\\

这个错误的解决方法很简单,就是打开dos时,以管理员身份打开就行了。

更新:今天在另外一台机器上按照上述方法安装时,还是报错:

Exception:
Traceback (most recent call last):
  File "C:\Users\413\Anaconda3\lib\shutil.py", line 381, in _rmtree_unsafe
    os.unlink(fullname)
PermissionError: [WinError 5] 拒绝访问。: 'C:\\Users\\413\\AppData\\Local\\Temp\\pip-mjk8iy_j-uninstall\\users\\413\\anaconda3\\lib\\site-packages\\scipy\\integrate\\lsoda.cp35-win_amd64.pyd'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\413\Anaconda3\lib\site-packages\pip\basecommand.py", line 215, in main
    status = self.run(options, args)
  File "C:\Users\413\Anaconda3\lib\site-packages\pip\commands\install.py", line 317, in run
    prefix=options.prefix_path,
  File "C:\Users\413\Anaconda3\lib\site-packages\pip\req\req_set.py", line 753, in install
    requirement.commit_uninstall()
  File "C:\Users\413\Anaconda3\lib\site-packages\pip\req\req_install.py", line 755, in commit_uninstall
    self.uninstalled.commit()
  File "C:\Users\413\Anaconda3\lib\site-packages\pip\req\req_uninstall.py", line 142, in commit
    rmtree(self.save_dir)
  File "C:\Users\413\Anaconda3\lib\site-packages\pip\_vendor\retrying.py", line 49, in wrapped_f
    return Retrying(*dargs, **dkw).call(f, *args, **kw)
  File "C:\Users\413\Anaconda3\lib\site-packages\pip\_vendor\retrying.py", line 212, in call
    raise attempt.get()
  File "C:\Users\413\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\413\Anaconda3\lib\site-packages\pip\_vendor\six.py", line 686, in reraise
    raise value
  File "C:\Users\413\Anaconda3\lib\site-packages\pip\_vendor\retrying.py", line 200, in call
    attempt = Attempt(fn(*args, **kwargs), attempt_number, False)
  File "C:\Users\413\Anaconda3\lib\site-packages\pip\utils\__init__.py", line 102, in rmtree
    onerror=rmtree_errorhandler)
  File "C:\Users\413\Anaconda3\lib\shutil.py", line 488, in rmtree
    return _rmtree_unsafe(path, onerror)
  File "C:\Users\413\Anaconda3\lib\shutil.py", line 378, in _rmtree_unsafe
    _rmtree_unsafe(fullname, onerror)
  File "C:\Users\413\Anaconda3\lib\shutil.py", line 378, in _rmtree_unsafe
    _rmtree_unsafe(fullname, onerror)
  File "C:\Users\413\Anaconda3\lib\shutil.py", line 378, in _rmtree_unsafe
    _rmtree_unsafe(fullname, onerror)
  File "C:\Users\413\Anaconda3\lib\shutil.py", line 378, in _rmtree_unsafe
    _rmtree_unsafe(fullname, onerror)
  File "C:\Users\413\Anaconda3\lib\shutil.py", line 378, in _rmtree_unsafe
    _rmtree_unsafe(fullname, onerror)
  File "C:\Users\413\Anaconda3\lib\shutil.py", line 378, in _rmtree_unsafe
    _rmtree_unsafe(fullname, onerror)
  File "C:\Users\413\Anaconda3\lib\shutil.py", line 378, in _rmtree_unsafe
    _rmtree_unsafe(fullname, onerror)
  File "C:\Users\413\Anaconda3\lib\shutil.py", line 383, in _rmtree_unsafe
    onerror(os.unlink, fullname, sys.exc_info())
  File "C:\Users\413\Anaconda3\lib\site-packages\pip\utils\__init__.py", line 114, in rmtree_errorhandler
    func(path)
PermissionError: [WinError 5] 拒绝访问。: 'C:\\Users\\413\\AppData\\Local\\Temp\\pip-mjk8iy_j-uninstall\\users\\413\\anaconda3\\lib\\site-packages\\scipy\\integrate\\lsoda.cp35-win_amd64.pyd'

解决方法:

按照这个命令进行安装就解决了:pip install --user -U imbalanced-learn

发布了97 篇原创文章 · 获赞 40 · 访问量 16万+

猜你喜欢

转载自blog.csdn.net/NOT_GUY/article/details/84729646