pyad:安装正常,但说找不到 adbase
pyad: Installs fine, but says it can't find adbase
这让我很困惑。我已经使用 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 找不到它。
这是 pyad 部分的错误。他们导入 adbase 就好像它是一个独立的模块或包一样,这就是它不起作用的原因。解决此问题的正确方法是将导入更改为绝对导入 from pyad.adbase import ...
或相对 from .adbase import ...
.
但是,如果您检查 master
branch on Github, you will see that they have actually fixed it. But that's not all, if you check their setup.py
,您会看到 Github 上的版本是 0.5.15
,而 PyPI 上的最新版本,即您已安装的版本, 是 0.5.16
。奇怪。
我建议您直接从 Github 安装软件包,这样应该可以解决问题。为此,首先卸载 pyad
,然后卸载 运行
pip install https://github.com/zakird/pyad/archive/master.zip
这让我很困惑。我已经使用 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 找不到它。
这是 pyad 部分的错误。他们导入 adbase 就好像它是一个独立的模块或包一样,这就是它不起作用的原因。解决此问题的正确方法是将导入更改为绝对导入 from pyad.adbase import ...
或相对 from .adbase import ...
.
但是,如果您检查 master
branch on Github, you will see that they have actually fixed it. But that's not all, if you check their setup.py
,您会看到 Github 上的版本是 0.5.15
,而 PyPI 上的最新版本,即您已安装的版本, 是 0.5.16
。奇怪。
我建议您直接从 Github 安装软件包,这样应该可以解决问题。为此,首先卸载 pyad
,然后卸载 运行
pip install https://github.com/zakird/pyad/archive/master.zip