博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Scrapy throws ImportError: cannot import name xmlrpc_client
阅读量:7041 次
发布时间:2019-06-28

本文共 2182 字,大约阅读时间需要 7 分钟。

After install Scrapy via pip, and having Python 2.7.10:

scrapyTraceback (most recent call last):File "/usr/local/bin/scrapy", line 7, in 
from scrapy.cmdline import executeFile "/Library/Python/2.7/site-packages/scrapy/__init__.py", line 48, in
from scrapy.spiders import SpiderFile "/Library/Python/2.7/site-packages/scrapy/spiders/__init__.py", line 10, in
from scrapy.http import RequestFile "/Library/Python/2.7/site-packages/scrapy/http/__init__.py", line 12, in
from scrapy.http.request.rpc import XmlRpcRequestFile "/Library/Python/2.7/site-packages/scrapy/http/request/rpc.py", line 7, in
from six.moves import xmlrpc_client as xmlrpclibImportError: cannot import name xmlrpc_client

 

 

six.moves is a virtual namespace. It provides access to packages that were renamed between Python 2 and 3. As such, you shouldn't be installing anything.

By importing from six.moves.xmlrpc_client the developer doesn't have to handle the case where it is located at  in Python 2, and at  in Python 3. Note that these are part of the standard library.

The mapping was added to ; make sure you have that version or newer.

Mac comes with six version 1.4.1 pre-installed in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python and this will interfere with any version you install in site-packages (which is listed last in the sys.path).

The best work-around is to use a  and install your own version of six into that, together with whatever else you need for this project. Create a new virtualenv for new projects.

If you absolutely have to install this at the system level, then for this specific project you'll have to remove the /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python path:

import syssys.path.remove('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python')

This will remove various OS X-provided packages from your path for just that run of Python; Apple installs these for their own needs.

 

解决方案:

  sudo pip uninstall six

  easy_install six

 

转载于:https://www.cnblogs.com/kristain/articles/4825900.html

你可能感兴趣的文章
程序员的修养 -- 如何写日志(logging)
查看>>
[Splay]Luogu 3960 NOIP2017 列队
查看>>
网络流——最大流问题例题
查看>>
数据恢复:模拟2个逻辑坏块
查看>>
SDUT 1124-飞跃荒野(三维BFS)
查看>>
wcf 请考虑增加操作超时
查看>>
【设计模式】简单工厂模式
查看>>
[LeetCode] Binary Tree Paths 二叉树路径
查看>>
对JAVA集合进行遍历删除时务必要用迭代器
查看>>
poj 2010 Moo University - Financial Aid(优先队列(最小堆)+ 贪心 + 枚举)
查看>>
统计多少个汉字与字母
查看>>
Odoo9发行说明
查看>>
logging日志管理--将日志打印在屏幕上
查看>>
PF_NETLINK应用实例NETLINK_KOBJECT_UEVENT具体实现--udev实现原理
查看>>
mongodb 3.x 之实用新功能窥看[2] ——使用$lookup做多表关联处理
查看>>
实际利率 > 名义利率
查看>>
第三篇:基于K-近邻分类算法的手写识别系统
查看>>
9.6智力题(一)——给定两条绳子,每条绳子燃烧殆尽正好用一个小时,用这两条绳子准确计时15分钟...
查看>>
启动redis
查看>>
Swift 互斥锁写法
查看>>