推荐学习书目
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 · Apr 2, 2015 · 4059 views
    This topic created in 4073 days ago, the information mentioned may be changed or developed.
    我的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 replies    2015-04-06 11:35:04 +08:00
    junnplus
        1
    junnplus  
       Apr 2, 2015
    试试打开交互式python单独导入,,,
    weiyang512
        2
    weiyang512  
    OP
       Apr 2, 2015
    @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  
       Apr 5, 2015
    提示很明显了.=>没有属性
    weiyang512
        4
    weiyang512  
    OP
       Apr 6, 2015
    @ming2281 感觉这像是一个bug,有时候能执行,有时候不行。那个AtrributeErro在单独import inspect也是时有时无的
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4134 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 10:11 · PVG 18:11 · LAX 03:11 · JFK 06:11
    ♥ Do have faith in what you're doing.