[英]python3 bdist_egg cannot install in python2?
我的setup.py
是這樣的:
#!/usr/bin/env python
# encoding: utf-8
from setuptools import setup
setup(name='demo',
version='0.0.1',
packages=["demo"],
package_dir={'demo':'demo'},
install_requires=["requests"],
)
然后我發散:
source activate py3
python setup.py bdist_eg
我在python 3.6
運行它, setuptools==36.2.7
,得到像下面這樣的egg文件: dist/demo-0.0.1-py3.6.egg
。 我安裝了這個egg文件,在python3中沒有任何錯誤。
但是,如果要在python 2.7
安裝此egg文件,請運行以下命令:
source activate py2
easy_install dist/demo-0.0.1-py3.6.egg
我有這樣的錯誤:
error: Could not find suitable distribution for Requirement.parse('demo==0.0.1')
如今的最佳做法是使用滾輪格式(而不是egg)並使用pip進行安裝。
在您的virtualenv中:
pip install wheel
python setup.py bdist_wheel
在dist
目錄中,您將創建一個.whl文件。
然后在py2 virtualenv中,您可以執行以下操作:
pip install your-lib-xyz.whl
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.