[英]Installing via `setup.py develop` fails - pip works
我的python包footools
需要通过setup.py
install_requires
来footools
html5lib。
通过setup.py develop
安装失败:
cd src/footools/
python setup.py develop
Processing dependencies for footools==2016.205
Searching for html5lib==0.9999999
Reading https://source.example.com/pypi/simple/html5lib/
Download error on https://source.example.com/pypi/simple/html5lib/:
[Errno 185090050] _ssl.c:354: error:0B084002:x509
certificate routines:X509_load_cert_crl_file:system lib --
Some packages may not be found!
Couldn't find index page for 'html5lib' (maybe misspelled?)
但是直接下载有效:
bar@workdevel123:~/src/footools> pip install html5lib==0.9999999
/home/bar/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:79:
InsecurePlatformWarning: A true SSLContext object is not available.
This prevents urllib3 from configuring SSL appropriately
and may cause certain SSL connections to fail.
For more information, see
https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Collecting html5lib==0.9999999
/home/bar/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:79:
InsecurePlatformWarning: A true SSLContext object is not available.
This prevents urllib3 from configuring SSL appropriately and
may cause certain SSL connections to fail.
For more information,
see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Downloading https://source.example.com/pypi/packages/html5lib-0.9999999.tar.gz
Requirement already satisfied (use --upgrade to upgrade):
six in /usr/lib/python2.7/site-packages (from html5lib==0.9999999)
Installing collected packages: html5lib
Running setup.py install for html5lib
Successfully installed html5lib-0.9999999
这两种方法有什么区别?
他们为什么不同?
在python中安装依赖项的正确方法是什么?
setup.py
并不特别:
import setuptools
setuptools.setup(
name='foo',
version='2016.210',
long_description=open('README.txt').read(),
packages=setuptools.find_packages(),
install_requires=[
# about twenty packages before this line
'html5lib==0.9999999'
],
include_package_data=True,
entry_points={
'console_scripts': [
'foo=foo.utils.bar:main',
],
},
)
python setup.py develop
或setuptools
通常使用easy_install
来满足依赖关系,而依赖关系依次使用urllib2
而pip
使用requests
。 请看这里easy_install vs pip 。
pip
更现代,除此之外还有能力卸载软件包并符合PEP 438 - 在PyPI上过渡到发布文件托管 。 您可以使用pip install -e src/footools/
实现与python setup.py develop
,注意项目路径是否在当前目录中使用,。/ ./footools
。
requests
包捆绑了包本身的证书, python -c 'import pip;print(pip.download.requests.certs.where())'
。
setuptools
使用系统安装的ca certs python -c 'from setuptools import ssl_support;print(ssl_support.cert_paths)'
。
您必须使用诸如Ubuntu的update-ca-certificates
类的工具更新系统安装的ca证书,以自动更新ca证书或从https://curl.haxx.se/docs/caextract.html下载并安装到显示的其中一个路径中通过setuptools
或将setuptools.ssl_support.cert_paths
设置为像[]
这样的empy序列并执行pip install certifi
。 调用setuptools.ssl_support.find_ca_bundle()
将显示ca证书的位置。
setuptools是Python distutils(适用于Python 2.6及更高版本)的增强功能集,允许开发人员更轻松地构建和分发Python包,尤其是那些依赖于其他包的Python包。
因此,除了其他功能外,您还可以创建可以上传到Pypi的软件包,然后使用pip
安装(因此可以解析您的模块)。
也就是说,它们在安装部分实际上应该不同。 您正在运行develop
模式,因此您可能需要对目录进行一些操作或修复授权错误。
在开发模式中 ,项目部署到临时区域(在某种程度上类似于虚拟环境的过程)
部署是以这样一种方式完成的,即在暂存区域中可立即对项目源进行更改,而无需在每次更改后运行构建或安装步骤。
意思也是该python解释器可用的一切。 它可以在以后取消暂停。
我注意到html5lib
是从不同的地方获取的: /pypi/simple/
在一个case中, /pypi/packages/
在另一个中。
dependency_links
在满足依赖关系时命名要搜索的URL的字符串列表。 如果需要安装setup_requires或tests_require指定的包,将使用这些链接。
回到问题我认为它很可能是ssl问题,因为在pip中它处理得很好(即,很好的警告并且有某种解决方法),但是setuptools不会发生这种情况。 如果未处理的请求中存在错误,则Couldn't find index page for 'html5lib'
。
除了不同的用户界面之外,对用户来说,没什么特别重要的。 他们是乘坐Python套餐管理的历史悠久的火车车程的两站。 沿途还有其他人。
在当天,Python没有附带包管理系统。 第三方解决方案填补了空白。 它们是由不同的人在不同的时刻设计的。 如果你看看其他编程语言,你有时会看到类似的故事; 有时你看到更快乐的故事; 有时更悲惨。
这两种方法在技术上都是正确的。 Pip是一种更现代的方法,根据我的经验,它更受欢迎,也更方便。 从Python 3.4及更高版本开始,Pip已经包含在CPython发行版中,并且是正式“首选”。 所以你可以看到风吹的方向。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.