环境: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