pyad: Installs fine, but says it can't find adbase

女生的网名这么多〃 提交于 2019-12-01 06:04:57

问题


This has me pretty confused. I've installed pyad using pip and everything seems fine:

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

But when I try to use it, I get an error that complains about not finding 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'

This is odd, because if I try to uninstall pyad or if I check the site-packages directory, adbase is definitely there:

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

I'm really not sure what else to try. I've run everything under an elevated command prompt, so it's not a permissions issue. I even tried downloading pyad and installing it using setup.py, but I had the same problem with that. adbase is definitely there, and I can't figure out why Python isn't finding it.


回答1:


That's a bug on pyad part. They're importing adbase as if it were a standalone module or package, and that's why it does not work. The proper way to fix this would be to change the import to an absolute import from pyad.adbase import ... or relative from .adbase import ....

However, if you check the master branch on Github, you will see that they have actually fixed it. But that's not all, if you check their setup.py you'll see that the version on Github is 0.5.15, while the last version on PyPI, which is the one you have installed, is 0.5.16. Weird.

I suggest you to install the package directly from Github, and that should take care of the problem. To do that, first uninstall pyad and then run

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


来源:https://stackoverflow.com/questions/40004147/pyad-installs-fine-but-says-it-cant-find-adbase

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!