pyad:安装得很好,但说无法找到adbase

时间:2016-10-12 16:51:52

标签: python pip pyad

这让我非常困惑。我用pip安装了pyad,一切似乎都很好:

C:\WINDOWS\system32>pip install pyad
Collecting pyad
  Using cached pyad-0.5.16.tar.gz
Requirement already satisfied (use --upgrade to upgrade): setuptools in c:\python35\lib\site-packages (from pyad)
Requirement already satisfied (use --upgrade to upgrade): pywin32 in c:\python35\lib\site-packages (from pyad)
Installing collected packages: pyad
  Running setup.py install for pyad ... done
Successfully installed pyad-0.5.16

但是当我尝试使用它时,我收到一个错误,抱怨没有找到adbase:

C:\WINDOWS\system32>python
Python 3.5.1 (v3.5.1:37a07cee5969, Dec  6 2015, 01:54:25) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from pyad import aduser
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python35\lib\site-packages\pyad\__init__.py", line 1, in <module>
    from adbase import set_defaults as pyad_setdefaults
ImportError: No module named 'adbase'
>>> import pyad
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python35\lib\site-packages\pyad\__init__.py", line 1, in <module>
    from adbase import set_defaults as pyad_setdefaults
ImportError: No module named 'adbase'

这很奇怪,因为如果我尝试卸载pyad或者如果我检查了site-packages目录,那么adbase绝对存在:

C:\WINDOWS\system32>pip uninstall pyad
Uninstalling pyad-0.5.16:
  c:\python35\lib\site-packages\pyad-0.5.16-py3.5.egg-info
  c:\python35\lib\site-packages\pyad\__init__.py
  c:\python35\lib\site-packages\pyad\__pycache__\__init__.cpython-35.pyc
  c:\python35\lib\site-packages\pyad\__pycache__\adcomputer.cpython-35.pyc
  c:\python35\lib\site-packages\pyad\__pycache__\addomain.cpython-35.pyc
  c:\python35\lib\site-packages\pyad\__pycache__\adgroup.cpython-35.pyc
  c:\python35\lib\site-packages\pyad\__pycache__\adquery.cpython-35.pyc
  c:\python35\lib\site-packages\pyad\__pycache__\adsearch.cpython-35.pyc
  c:\python35\lib\site-packages\pyad\__pycache__\pyad.cpython-35.pyc
  c:\python35\lib\site-packages\pyad\adbase.py
  c:\python35\lib\site-packages\pyad\adcomputer.py
  c:\python35\lib\site-packages\pyad\adcontainer.py
  c:\python35\lib\site-packages\pyad\addomain.py
  c:\python35\lib\site-packages\pyad\adgroup.py
  c:\python35\lib\site-packages\pyad\adobject.py
  c:\python35\lib\site-packages\pyad\adquery.py
  c:\python35\lib\site-packages\pyad\adsearch.py
  c:\python35\lib\site-packages\pyad\aduser.py
  c:\python35\lib\site-packages\pyad\pyad.py
  c:\python35\lib\site-packages\pyad\pyadconstants.py
  c:\python35\lib\site-packages\pyad\pyadexceptions.py
  c:\python35\lib\site-packages\pyad\pyadutils.py
Proceed (y/n)?

pyad directory contents

我真的不确定还有什么可以尝试的。我在提升的命令提示符下运行所有​​内容,因此它不是权限问题。我甚至尝试下载pyad并使用setup.py安装它,但我遇到了同样的问题。 adbase肯定 那里,我无法弄清楚为什么Python找不到它。

1 个答案:

答案 0 :(得分:7)

这是pyad部分的一个错误。他们正在导入广告库,就像它是一个独立的模块或软件包一样,这就是它无效的原因。解决此问题的正确方法是将导入更改为绝对导入from pyad.adbase import ...或相对from .adbase import ...

但是,如果你检查Github上的master分支,你会发现他们已经修复了它。但这并不是全部,如果你检查他们的setup.py你会发现Github上的版本是0.5.15,而PyPI上的最后一个版本是你安装的版本,是0.5.16。怪异。

我建议你直接从Github安装软件包,这应该解决问题。为此,请先卸载pyad,然后再运行

pip install https://github.com/zakird/pyad/archive/master.zip