How do I install six.moves.xmlrpc_client?
I am copying a piece of code from openstack, but when it works:
import six.moves.xmlrpc_client as xmlrpclib
I got the following error:
import six.moves.xmlrpc_client as xmlrpclib
ImportError: No module named xmlrpc_client
I installed the package six
. How to solve this problem?
I am working on macOS with python 2.7.
I tried to install but couldn't:
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:
But when I run my program I still have the same error. How to solve a problem?
source to share
six.moves
- virtual namespace. It provides access to packages that were renamed between Python 2 and 3. So you don't have to install anything.
When importing from, the six.moves.xmlrpc_client
developer does not need to handle the case when it is in xmlrpclib
Python 2 and xmlrpc.client
in Python 3. Note that this is part of the standard library.
The mapping was added in six
version 1.5.0 ; make sure you have this version or newer.
The Mac comes with six versions 1.4.1 preinstalled in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
, and this will interfere with whatever version you install in site-packages
(which is listed last in sys.path).
The best job is to use virtualenv and install your own version into it six
, along with anything else you need this project. Create a new virtualenv for new projects.
If you absolutely need to set this at the system level, then for this particular project you will have to remove the path /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
:
import sys
sys.path.remove('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python')
This will remove the various packages that come with OS X from your path for that Python run; Apple installs them for its own needs.
source to share