我使用的是Windows,我需要从here安装WHL文件。这是我在setup.py中的内容:
install_requires=['mysqlclient==1.3.7',
...
dependency_links=['https://pypi.python.org/packages/cp27/m/mysqlclient/mysqlclient-1.3.7-cp27-none-win32.whl#md5=e9e726fd6f1912af78e2bf6ab56c02f3',]
然而,setuptools正在下载tar.gz文件,并尝试构建,这不会对我的系统起作用。我关注this solution并将install_requires
更改为使用mysqlclient<=1.3.7
,但我仍然遇到同样的问题。这是输出:
Searching for mysqlclient<=1.3.7
Reading https://pypi.python.org/packages/cp27/P/Pillow/Pillow-2.7.0-cp27-none-win32.whl#md5=ebc4ef88a8dd39ed484206323a8d557a
Reading https://pypi.python.org/packages/cp27/m/mysqlclient/mysqlclient-1.3.7-cp27-none-win32.whl#md5=e9e726fd6f1912af78e2bf6ab56c02f3
Reading http://pypi.python.org/simple/mysqlclient/
Best match: mysqlclient 1.3.7
Downloading https://pypi.python.org/packages/source/m/mysqlclient/mysqlclient-1.3.7.tar.gz#md5=2ec5a96cbd9fd6ef343fa9b581a67fc4
Processing mysqlclient-1.3.7.tar.gz
Running mysqlclient-1.3.7\setup.py -q bdist_egg --dist-dir c:\users\uuu\appdata\local\temp\easy_install-wt7fkw\mysqlclient-1.3.7\egg-dist-tmp-ubrs4f
error: Setup script exited with error: Unable to find vcvarsall.bat
我在使用dependency_links中的链接安装Pillow时没有任何问题。有没有办法强制setup.py使用依赖关系链接?
答案 0 :(得分:2)
我最终手动安装软件包作为安装后的一部分:
from setuptools.command.install import install as _install
import pip
class install(_install):
def run(self):
_install.do_egg_install(self)
# Even when dependeny link to mysqlclient is specified, setuptools still installs
# from pypi, which does not work on Windows. Therefore, manually install mysqlclient
if os.name == 'nt':
pip.main(['install', 'https://pypi.python.org/packages/cp27/m/mysqlclient/mysqlclient-1.3.7-cp27-none-win32.whl#md5=e9e726fd6f1912af78e2bf6ab56c02f3'])
else:
pip.main(['install', 'mysqlclient==1.3.7'])
setup(
cmdclass={'install': install},
...
)
有other answers致电_install.run()
,但这对我不起作用。我不得不使用do_egg_install()
。