当我使用以下命令升级用户的pip存储库时:
pip freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs pip install -U
我收到以下错误消息:
Exception:
Traceback (most recent call last):
File "/home/peng/.local/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/home/peng/.local/lib/python2.7/site-packages/pip/commands/install.py", line 317, in run
prefix=options.prefix_path,
File "/home/peng/.local/lib/python2.7/site-packages/pip/req/req_set.py", line 742, in install
**kwargs
File "/home/peng/.local/lib/python2.7/site-packages/pip/req/req_install.py", line 831, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/home/peng/.local/lib/python2.7/site-packages/pip/req/req_install.py", line 1032, in move_wheel_files
isolated=self.isolated,
File "/home/peng/.local/lib/python2.7/site-packages/pip/wheel.py", line 346, in move_wheel_files
clobber(source, lib_dir, True)
File "/home/peng/.local/lib/python2.7/site-packages/pip/wheel.py", line 330, in clobber
os.utime(destfile, (st.st_atime, st.st_mtime))
OSError: [Errno 1] Operation not permitted: '/usr/local/lib/python2.7/dist-packages/easy_install.pyc'
但是,触发此错误的文件已经打开了所有权限:
ls /usr/local/lib/python2.7/dist-packages/easy_install.pyc -l
-rwxrwxrwx 1 root staff 315 Jul 5 20:47 /usr/local/lib/python2.7/dist-packages/easy_install.pyc
为什么pip仍然无法继续工作?要解决这个问题需要做些什么?
答案 0 :(得分:2)
我在使用不同于python文件所有者的用户运行pip install
时遇到此错误。这是Linux的一个奇怪(和丑陋)限制:任何具有写入权限的用户都可以将文件时间设置为当前时间(触摸),但只有文件所有者可以设置任意时间。 pip / wheel正试图设置确切的时间,内核不允许它。
相关点子问题:https://github.com/pypa/pip/issues/2125
Beta(比nuthin)解决方案是更改文件所有者或以文件所有者用户身份运行pip。
我正在拼命寻找更好的解决方案,请在评论中提供帮助。