R.h*_*hui 34 python macos sudo six
我试图使用刮,但我有一个问题.
从six.moves导入xmlrpc_client作为xmlrpclib
ImportError:无法导入名称xmlrpc_client
然后,我尝试了pip install --upgrade six scrape,但是:
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 211, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip/commands/install.py", line 311, in run
root=options.root_path,
File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 640, in install
requirement.uninstall(auto_confirm=True)
File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 716, in uninstall
paths_to_remove.remove(auto_confirm)
File "/Library/Python/2.7/site-packages/pip/req/req_uninstall.py", line 125, in remove
renames(path, new_path)
File "/Library/Python/2.7/site-packages/pip/utils/__init__.py", line 315, 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: '/var/folders/3h/r_2cxlvd1sjgzfgs4xckc__c0000gn/T/pip-5h86J8-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info'
Run Code Online (Sandbox Code Playgroud)
ste*_*ner 52
快速解决:
我只是绕过了我认为同样的问题.您可以考虑尝试这个(sudo,如果有必要):
pip install scrape --upgrade --ignore-installed six
Github最终得到了这个答案(如果这个问题没有解决你的问题,你可以考虑更多的建议).这似乎也是El Capitan问题.
此外,这在技术上可能是重复的.但另一篇文章提出的答案是安装自己的Python而不是依赖于默认的osx Python,这让我更加费力.
更长,真正的修复:
最终我遇到了一个实际需要升级的情况six,以便安装其他一些库,此时忽略是不够的.为我升级六个最简单的方法是不使用pip,而是手动.tar.gz从六页下载,解压缩,移动到新解压缩的六个包目录,然后手动运行安装(sudo,如果需要):
python setup.py install
小智 20
我不认为这是重复的,但实际上这个问题在pip GitHub存储库问题列表中讨论过.
注意: 根据您要安装的软件包,您可能需要修改解决方案中引用的命令.在我的情况下,我试图设置virtualenv和virtualwrapper.如果您未能安装aws-cli或任何其他软件包,只需将其插入脚本即可
问题的核心与他们随El Capitan一起提供的Apple新SIP相关联.更具体地说,
OS X 10.11的python保留了自己的六个副本,这是不可删除的,因为Apple对他们的python发行版进行了修改.1.4.1不是最新的,1.10.0是.它也早在他们的python的导入路径上,所以它通常会覆盖你安装的更高版本.
我建议现在使用不同的python.Python.org,或通过Homebrew或Anaconda Python安装.
有一个在向不同的堆栈交流极为细致的讨论,讨论了如何与SIP的问题已经确定,解决,因为埃尔卡皮坦原始版本的演变.虽然我发现它很吸引人,但是按照下面的说明你花费的时间少于你阅读它的时间,所以我建议你在完成以下操作后检查它...
尝试升级VirtualEnv和VirtualEnvWrapper时遇到了完全相同的错误.在上面的线程中有几个建议,但最终最稳定的是
$ man sudo
-H The -H (HOME) option option sets the HOME environment variable
to the home directory of the target user (root by default) as specified
HOME environment variable depends on sudoers(5) settings. By default,
sudo will set HOME if env_reset or always_set_home are set, or if
set_home is set and the -s option is specified on the command line.
Run Code Online (Sandbox Code Playgroud)
$ pip install --help | grep upgrade
-U, --upgrade Upgrade all specified packages to the newest available
version. This process is recursive regardless of whether a dependency
is already satisfied.
beejhuff@ignatius:~/mac_setup$ pip install --help | grep ignore-installed
-I, --ignore-installed Ignore the installed packages (reinstalling instead).
Run Code Online (Sandbox Code Playgroud)
首先,我原来的尝试和错误:
$ sudo pip install virtualenv virtualenvwrapper
The directory '/Users/beejhuff/Library/Caches/pip/http' or its parent directory
is not owned by the current user and the cache has been disabled.
Please check the permissions and owner of that directory. If executing
pip with sudo, you may want sudo's -H flag.
The directory '/Users/beejhuff/Library/Caches/pip' or its parent directory
is not owned by the current user and caching wheels has been disabled.
check the permissions and owner of that directory. If executing pip with
sudo, you may want sudo's -H flag.
Collecting virtualenv
Downloading virtualenv-15.0.0-py2.py3-none-any.whl (1.8MB)
100% |????????????????????????????????| 1.8MB 335kB/s
Collecting virtualenvwrapper
Downloading virtualenvwrapper-4.7.1-py2.py3-none-any.whl
Collecting virtualenv-clone (from virtualenvwrapper)
Downloading virtualenv-clone-0.2.6.tar.gz
Collecting stevedore (from virtualenvwrapper)
Downloading stevedore-1.12.0-py2.py3-none-any.whl
Collecting pbr>=1.6 (from stevedore->virtualenvwrapper)
Downloading pbr-1.8.1-py2.py3-none-any.whl (89kB)
100% |????????????????????????????????| 92kB 362kB/s
Collecting six>=1.9.0 (from stevedore->virtualenvwrapper)
Downloading six-1.10.0-py2.py3-none-any.whl
Installing collected packages: virtualenv, virtualenv-clone, pbr, six, stevedore, virtualenvwrapper
Running setup.py install for virtualenv-clone ... 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-8.1.0-py2.7.egg/pip/basecommand.py", line 209, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip-8.1.0-py2.7.egg/pip/commands/install.py", line 317, in run
prefix=options.prefix_path,
File "/Library/Python/2.7/site-packages/pip-8.1.0-py2.7.egg/pip/req/req_set.py", line 726, in install
requirement.uninstall(auto_confirm=True)
File "/Library/Python/2.7/site-packages/pip-8.1.0-py2.7.egg/pip/req/req_install.py", line 746, in uninstall
paths_to_remove.remove(auto_confirm)
File "/Library/Python/2.7/site-packages/pip-8.1.0-py2.7.egg/pip/req/req_uninstall.py", line 115, in remove
renames(path, new_path)
File "/Library/Python/2.7/site-packages/pip-8.1.0-py2.7.egg/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-GQL8Gi-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info'
Run Code Online (Sandbox Code Playgroud)
解决方案
它需要以三种具体方式修改我的安装命令:
-H标志sudo--upgrade在我正在升级的包的名称之后添加选项(virtualenv)--ignore-installed标志并指定six包是被忽略的包.$ sudo -H pip install <packagename> --upgrade --ignore-installed six- 替换<packagename>您需要安装的特定包最后的工作实例
第一次升级virtualenv
$ sudo -H pip install virtualenv --upgrade --ignore-installed six
Password:
Collecting virtualenv
Using cached virtualenv-15.0.0-py2.py3-none-any.whl
Collecting six
Using cached six-1.10.0-py2.py3-none-any.whl
Installing collected packages: virtualenv, six
Successfully installed six-1.4.1 virtualenv-15.0.0
Run Code Online (Sandbox Code Playgroud)
第二次升级virtualenvwrapper
$ sudo -H pip install virtualenvwrapper --upgrade --ignore-installed six
Password:
Downloading virtualenvwrapper-4.7.1-py2.py3-none-any.whl
Collecting six
Downloading six-1.10.0-py2.py3-none-any.whl
Collecting virtualenv (from virtualenvwrapper)
Downloading virtualenv-15.0.0-py2.py3-none-any.whl (1.8MB)
100% |????????????????????????????????| 1.8MB 751kB/s
Collecting virtualenv-clone (from virtualenvwrapper)
Downloading virtualenv-clone-0.2.6.tar.gz
Collecting stevedore (from virtualenvwrapper)
Downloading stevedore-1.12.0-py2.py3-none-any.whl
Collecting pbr>=1.6 (from stevedore->virtualenvwrapper)
Downloading pbr-1.8.1-py2.py3-none-any.whl (89kB)
100% |????????????????????????????????| 92kB 417kB/s
Installing collected packages: virtualenv, virtualenv-clone, pbr, six, stevedore, virtualenvwrapper
Running setup.py install for virtualenv-clone ... done
Successfully installed pbr-1.8.1 six-1.4.1 stevedore-1.12.0 virtualenv-15.0.0 virtualenv-clone-0.2.6 virtualenvwrapper-4.7.1
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15360 次 |
| 最近记录: |