概述
Could not install packages due to an EnvironmentError/OSError: [Errno 39] Directory not empty: 'xxx'錯誤及解決方式
- 前言
- 發生場景1
- 發生場景2
- 解決辦法
前言
筆者曾經碰過這個錯誤兩次,雖然錯誤訊息不太一樣,但仍然可以採用相同的解決辦法。
發生場景1
這是筆者在使用pip
升級notebook
這個包時所出現的錯誤:
pip install notebook --upgrade
pip輸出訊息的前半部只是從網路下載包的log,以下展示的是比較重要的後半部份。
Installing collected packages: tornado, ptyprocess, terminado, jupyter-core, nbformat, six, bleach, testpath, MarkupSafe, jinja2, mistune, pygments, defusedxml, nbconvert, pyzmq, python-dateutil, jupyter-client, prompt-toolkit, backcall, decorator, parso, jedi, pickleshare, setuptools, pexpect, ipython, ipykernel, prometheus-client, Send2Trash, notebook
Found existing installation: tornado 4.5.1
Uninstalling tornado-4.5.1:
Exception:
Traceback (most recent call last):
File “/usr/lib/python3.5/shutil.py”, line 538, in move
os.rename(src, real_dst)
OSError: [Errno 18] Invalid cross-device link: ‘/usr/local/lib/python3.5/dist-packages/tornado-4.5.1-py3.5.egg-info’ -> ‘/tmp/pip-zlc_di8p-uninstall/usr/local/lib/python3.5/dist-packages/tornado-4.5.1-py3.5.egg-info’During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “/usr/local/lib/python3.5/dist-packages/pip/basecommand.py”, line 215, in main
status = self.run(options, args)
File “/usr/local/lib/python3.5/dist-packages/pip/commands/install.py”, line 342, in run
prefix=options.prefix_path,
File “/usr/local/lib/python3.5/dist-packages/pip/req/req_set.py”, line 778, in install
requirement.uninstall(auto_confirm=True)
File “/usr/local/lib/python3.5/dist-packages/pip/req/req_install.py”, line 754, in uninstall
paths_to_remove.remove(auto_confirm)
File “/usr/local/lib/python3.5/dist-packages/pip/req/req_uninstall.py”, line 115, in remove
renames(path, new_path)
File “/usr/local/lib/python3.5/dist-packages/pip/utils/init.py”, line 267, in renames
shutil.move(old, new)
File “/usr/lib/python3.5/shutil.py”, line 550, in move
rmtree(src)
File “/usr/lib/python3.5/shutil.py”, line 478, in rmtree
onerror(os.rmdir, path, sys.exc_info())
File “/usr/lib/python3.5/shutil.py”, line 476, in rmtree
os.rmdir(path)
OSError: [Errno 39] Directory not empty: ‘/usr/local/lib/python3.5/dist-packages/tornado-4.5.1-py3.5.egg-info’
You are using pip version 9.0.1, however version 18.1 is available.
You should consider upgrading via the ‘pip install --upgrade pip’ command.
發生場景2
python -m pip install --upgrade --force pip
Collecting pip
Downloading https://files.pythonhosted.org/packages/c2/d7/90f34cb0d83a6c5631cf71dfe64cc1054598c843a92b400e55675cc2ac37/pip-18.1-py2.py3-none-any.whl (1.3MB)
Installing collected packages: pip
Found existing installation: pip 18.1
Uninstalling pip-18.1:
Could not install packages due to an EnvironmentError: [Errno 39] Directory not empty: ‘/root/miniconda/envs/test-environment/lib/python2.7/site-packages/pip/_internal/cli’The command ‘/bin/sh -c /$HOME/miniconda/envs/test-environment/bin/python -m pip install --upgrade --force pip’ returned a non-zero code: 1
解決辦法
解決辦法就是在後面加上--ignore-installed
,變成:
pip install notebook --upgrade --ignore-installed
及
python -m pip install --upgrade --force --ignore-installed pip
最后
以上就是活泼烤鸡为你收集整理的Could not install packages due to an EnvironmentError/OSError: [Errno 39] Directory not empty: 'xxx'前言發生場景1發生場景2解決辦法的全部内容,希望文章能够帮你解决Could not install packages due to an EnvironmentError/OSError: [Errno 39] Directory not empty: 'xxx'前言發生場景1發生場景2解決辦法所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复