V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
weiyang512
V2EX  ›  Python

python importError 求帮助

  •  1
     
  •   weiyang512 · 2015-04-02 11:37:37 +08:00 · 3529 次点击
    这是一个创建于 3320 天前的主题,其中的信息可能已经有所发展或是发生改变。
    我的final.py文件前面的import几行是:
    #coding=utf-8
    import json, requests, fcntl, random
    from Queue import Queue, Empty, Full
    from threading import Thread, stack_size
    from pyquery import PyQuery

    一执行就是下面这个错误:
    Traceback (most recent call last):
    File "final.py", line 6, in <module>
    from pyquery import PyQuery
    File "/usr/local/lib/python2.7/dist-packages/pyquery/__init__.py", line 11, in <module>
    from .pyquery import PyQuery
    File "/usr/local/lib/python2.7/dist-packages/pyquery/pyquery.py", line 9, in <module>
    from lxml import etree
    File "parsertarget.pxi", line 4, in init lxml.etree (src/lxml/lxml.etree.c:200160)
    ImportError: cannot import name getargspec

    pip list关于pyquery和lxml的是:
    pyquery (1.2.9)
    lxml (3.3.6)

    python版本是2.7.6。搞了3个多钟了,建虚拟机、virtualenv都不行,求助各位帮忙解决啊,谢谢!
    4 条回复    2015-04-06 11:35:04 +08:00
    junnplus
        1
    junnplus  
       2015-04-02 12:48:26 +08:00
    试试打开交互式python单独导入,,,
    weiyang512
        2
    weiyang512  
    OP
       2015-04-02 14:08:33 +08:00
    @junnplus
    只输入from pyquery import PyQuery就是那个错误。在虚拟机里import pyquery没问题,但是一运行python final.py又是上面那个错误,然后再开终端import pyquery也有那个错误。搜了一下getargspec, 看到是inspect里的。import inspect之后执行inspect.getargspec()的得到错误提示是AttributeError: 'module' object has no attribute 'getargspec'。现在该怎么办?
    ming2281
        3
    ming2281  
       2015-04-05 12:32:10 +08:00
    提示很明显了.=>没有属性
    weiyang512
        4
    weiyang512  
    OP
       2015-04-06 11:35:04 +08:00
    @ming2281 感觉这像是一个bug,有时候能执行,有时候不行。那个AtrributeErro在单独import inspect也是时有时无的
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2221 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 04:41 · PVG 12:41 · LAX 21:41 · JFK 00:41
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.