how to install six.moves.xmlrpc_client?
我正在从OpenStack复制一些代码片段,但当它运行到:
1 | import six.moves.xmlrpc_client as xmlrpclib |
我有以下错误:
1 2 | import six.moves.xmlrpc_client as xmlrpclib ImportError: No module named xmlrpc_client |
我已经安装了
我正在用Python2.7开发MacOS。
我尝试安装但失败:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | lichaos-MacBook-Pro:common lichao$ sudo pip install --allow-unverified xmlrpclib xmlrpclib Collecting xmlrpclib xmlrpclib is potentially insecure and unverifiable. Downloading http://effbot.org/media/downloads/xmlrpclib-1.0.1.zip Installing collected packages: xmlrpclib Running setup.py install for xmlrpclib changing mode of build/scripts-2.7/xmlrpc_handler.py from 644 to 755 changing mode of build/scripts-2.7/xmlrpcserver.py from 644 to 755 changing mode of build/scripts-2.7/echotest.py from 644 to 755 changing mode of /usr/local/bin/echotest.py to 755 changing mode of /usr/local/bin/xmlrpc_handler.py to 755 changing mode of /usr/local/bin/xmlrpcserver.py to 755 Successfully installed xmlrpclib-1.0.1 $ sudo pip show six --- Name: six Version: 1.8.0 Location: /Library/Python/2.7/site-packages Requires: |
但当我运行我的程序时,仍然有同样的错误。如何解决这个问题?
通过从
已将映射添加到
Mac附带6个版本1.4.1,预装在
最好的解决方法是使用virtualenv并安装您自己的
如果您必须在系统级安装它,那么对于这个特定的项目,您必须删除
1 2 | import sys sys.path.remove('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python') |
这将从您的路径中删除各种OS X提供的包,仅用于运行python;苹果会根据自己的需要安装这些包。
1 2 | pip uninstall six pip install six |
应该解决这个问题。