【问题标题】:Creating setup.py for my python project , issue with downloading dependent packages为我的 python 项目创建 setup.py,下载依赖包时出现问题
【发布时间】:2013-12-01 07:06:16
【问题描述】:

这是我的 setup.py 文件

try:
   from setuptools import setup, find_packages
except ImportError:
   from ez_setup import use_setuptools
   use_setuptools()
   from setuptools import setup, find_packages

setup(
   name='test',
   version='0.1',
   description='',
   author='',
   author_email='',
   install_requires=[
      'django >= 1.2.3',
      'pyxmlsec',
      'south',
      'lxml',
      'xlrd'
   ],
   packages=find_packages(exclude=['ez_setup']),
   include_package_data=True,
   test_suite='nose.collector',
)

运行命令python setup.py install 后,它会在我的site_packges 中安装.egg,但在安装依赖项时会抛出错误:

 Processing dependencies for test==0.1
 Searching for lxml
 Reading https://pypi.python.org/simple/lxml/
 Download error on https://pypi.python.org/simple/lxml/: timed out -- Some packages may not be found!
 Couldn't find index page for 'lxml' (maybe misspelled?)
 Scanning index of all packages (this may take a while)
 Reading https://pypi.python.org/simple/
 Download error on https://pypi.python.org/simple/: timed out -- Some packages may not be found!
 No local packages or download links found for lxml
 error: Could not find suitable distribution for Requirement.parse('lxml')

不仅lxml 模块,所有其他模块(如xlrd)都会发生相同的错误。尝试的pypi 链接与源代码很好。那么有什么解决办法呢?提前致谢。

【问题讨论】:

  • 这是一个连接问题。你连接到互联网了吗?如果使用代理,您的代理设置是否在您的环境中正确(我假设是 linux)?您可以通过 pip install lxmleasy_install lxml 手动安装软件包
  • @RedBaron 是的,我可以手动安装模块,但实际上我希望在许多客户端机器中传输代码时,他们不应该手动下载和安装所有模块,运行一个简单的脚本就可以了那。所以我开发了这样的setup.py

标签: python django packaging setuptools setup.py


【解决方案1】:

许多用户报告 pypi downs 的问题,也许您可​​以使用 mirror 来解决,或者因为您有很多客户(我猜在同一个网络/组织中)local pypi server 应该是一个不错的解决方案,这里是一个列表pypi alternatives 我已经完成了。

【讨论】:

  • 感谢您的回复,我将尝试使用此mirror 解决方案。但是不能使用local pypi server,因为它们都不在asme网络中。
  • 也与当前脚本如何强制安装来自镜像服务器的所有依赖模块。任何想法:)
  • 试试this,也看看this answer,我没有测试过,但看起来很有用。此外,您可以在安装软件包时指示您的客户指定 pypi 服务器,即pip install -i http://pypi-mirror-server yourpackage
  • 似乎很有用的链接。
猜你喜欢
  • 2013-07-17
  • 2021-12-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-03-04
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多