0

Running setup.py install for anyjson ... done Found existing installation: six 1.4.1 DEPRECATION: Uninstalling a distutils installed project (six) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project. Uninstalling six-1.4.1: Exception: Traceback (most recent call last): File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 215, in main status = self.run(options, args) File "/Library/Python/2.7/site-packages/pip/commands/install.py", line 342, in run prefix=options.prefix_path, File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 778, in install requirement.uninstall(auto_confirm=True) File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 754, in uninstall paths_to_remove.remove(auto_confirm) File "/Library/Python/2.7/site-packages/pip/req/req_uninstall.py", line 115, in remove renames(path, new_path) File "/Library/Python/2.7/site-packages/pip/utils/__init__.py", line 267, in renames shutil.move(old, new) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 302, in move copy2(src, real_dst) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 131, in copy2 copystat(src, dst) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 103, in copystat os.chflags(dst, st.st_flags) OSError: [Errno 1] Operation not permitted: '/tmp/pip-29Cml5-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info'

错误堆栈跟踪的片段。在 python 上运行 requirements.txt 时。是不是因为六。

忽略它没有帮助。

sudo -H pip install -r requirements.txt --ignore-installed six Double requirement given: six==1.10.0 (from -r requirements.txt (line 107)) (already in six, name='six')

这篇文章没有帮助 - https://github.com/pypa/pip/issues/3165

4

1 回答 1

1

有时,Extras我要描述的问题不会影响 venvs。有时确实如此,但如果virtualenv完全可以选择使用,您应该在做任何其他事情之前尝试一下。

所以,让我们假设你要么不能这样做,要么你试过了,这是它实际上没有帮助的情况之一。


首先,让我说,除了安装Apple 在 OS X 10.7-10.13中使用 Apple 的 Python 2.7 预安装的新版本软件包之外,以下所有内容都是可怕的、糟糕的建议。Extras任何阅读本文的人如果不完全有这个问题,现在就停止阅读。

Apple 的 Python 2.7 系统版本附带一组漂亮的第三方软件包,预装在:

/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/

他们没有尝试使这些包保持最新,而是设计了一些东西,以便您可以轻松地使用site-packages目录中的较新版本来隐藏它们。这不是一个糟糕的主意。

不幸的是,他们停止对这几个版本的 OS X 进行任何认真的维护,但并没有停止发布它。特别是,他们从未将其更新为与setuptoolsand一起使用pip,如果您pip正确安装(使用get-pip.py脚本而不是easy_install),影子安装基本上将永远无法工作。


如果您的预安装easy_install仍然有效,它应该仍然可以安装阴影包。不要将它用于其他任何用途,但对于这个特定目的,它是正确的工具。但它并不适用于每个 OS X 版本上的每个包,因此需要反复试验。Extras您可能需要先备份site-packages以防万一。


测试它的方法(假设easy_install成功,当然——如果它失败并出现大量错误,它显然没有工作……是时候恢复你的备份了)是启动 Python import six,然后查看six.__version__or six.__file__。如果是 中的新版本site-packages,您就赢了。


如果这不起作用,有一个 hacky 解决方法可以解决您的问题:暂时将文件移动到Extras/lib/python/six-1.4.1-py2.7.egg-info其他地方,然后查看是否pip install six成功安装到您的正常site-packages. 如果是这样,请恢复 egg-info 文件,并再次测试阴影。


如果这仍然不起作用......好吧,您可以手动安装,但我认为在这一点上,并行安装两个 Python 2.7 的痛苦比管理你拥有的痛苦要少,所以我会考虑安装另一个(python.org、Anaconda 或 Homebrew),小心不要再碰苹果(virtualenv可以帮助解决这个问题)。

于 2018-04-04T22:32:05.207 回答