solution:AttributeError: 'module' object has no attribute 'PY2'

本文介绍了在安装web.py模块过程中遇到的错误及解决方案。当尝试使用pip安装web.py时出现AttributeError异常,提示'six'模块不存在'PY2'属性。解决办法是升级'six'模块,具体操作为使用sudo pip install --upgrade six命令。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

当我安装web.py模块(pip install web.py/ 
  sudo pip installweb.py)时出现了下面错误:
Exception:
Traceback (most recent call last):
  File"/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 122, inmain
      status =self.run(options, args)
  File"/usr/lib/python2.7/dist-packages/pip/commands/install.py", line278, in run
      requirement_set.prepare_files(finder,force_root_egg_info=self.bundle, bundle=self.bundle)
  File"/usr/lib/python2.7/dist-packages/pip/req.py", line 1229, inprepare_files
      req_to_install.run_egg_info()
  File"/usr/lib/python2.7/dist-packages/pip/req.py", line 292, inrun_egg_info
      logger.notify('Running setup.py (path:%s) egg_info for package %s'% (self.setup_py, self.name))
  File"/usr/lib/python2.7/dist-packages/pip/req.py", line 284, insetup_py
    ifsix.PY2 and isinstance(setup_py, six.text_type):
AttributeError: 'module' object has no attribute 'PY2'

Storing debug log for failure in /home/lzc/.pip/pip.log

解决方法:升级six,即sudo pip install --upgrade six 


If you six module has noPY2, the most likely reason is that you have anotherpackage named six somewhere. What does the following show if yourun it in the interpreter: import six; six.__file__Also, six.__version__.


>>>import six >>> six.__file__'/usr/local/lib/python2.7/dist-packages/six.pyc' >>>six.__version__ '1.3.0' –


Ok, your six is very old. I doubt it's the cause, butyou could try upgrading it: pip install --upgrade six.Can't really help you further if that's not it.
  

quotefrom:http://stackoverflow.com/questions/24081043/module-object-has-no-attribute-py2
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值