无法在 python 2.7 中导入 six.moves.xmlrpc_client

can't import six.moves.xmlrpc_client in python 2.7

环境:CENTOS 7

我的代码:

 import six.moves.xmlrpc_client as xmlrpclib

输出:

ImportError: No module named xmlrpc_client

python 口译员:

[root@dhcppc0 devstack]# python
Python 2.7.5 (default, Nov 20 2015, 02:00:19)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import six
>>> import six.moves
>>> import six.moves.xmlrpc_client
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named xmlrpc_client
>>>

六个版本:

[root@dhcppc0 devstack]# sudo yum install python-six
Loaded plugins: fastestmirror, priorities
Loading mirror speeds from cached hostfile
* base: centos.mirror.digitalpacific.com.au
* epel: mirror.overthewire.com.au
* extras: centos.mirror.digitalpacific.com.au
* updates: centos.mirror.digitalpacific.com.au
Package python-six-1.9.0-2.el7.noarch already installed and latest version
Nothing to do

XMLRPC 版本:

[root@dhcppc0 devstack]# sudo yum install xmlrpc-client.noarch
Loaded plugins: fastestmirror, priorities
Loading mirror speeds from cached hostfile
* base: centos.mirror.digitalpacific.com.au
* epel: fedora.mirror.serversaustralia.com.au
* extras: centos.mirror.digitalpacific.com.au
* updates: centos.mirror.digitalpacific.com.au
Package 1:xmlrpc-client-3.1.3-8.el7.noarch already installed and latest version
Nothing to do
[root@dhcppc0 devstack]#

知道为什么我无法在 python 2.7 安装中导入 six.moves.xmlrpc_client 吗?

谢谢

我的问题是我的系统上安装了多个 python 版本。解决此问题的方法是在您的系统上手动安装六个:

# wget https://pypi.python.org/packages/source/s/six/six-1.10.0.tar.gz#md5=34eed507548117b2ab523ab14b2f8b55
# tar -zxvf six-1.10.0.tar.gz
# python ./six-1.10.0/setup.py install

# python -c 'import six; print(six.__version__)'
1.10.0