[英]python3 bdist_egg cannot install in python2?
My setup.py
is like this: 我的
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"],
)
then I dist it: 然后我发散:
source activate py3
python setup.py bdist_eg
I run it in python 3.6
, setuptools==36.2.7
, get egg file like this: dist/demo-0.0.1-py3.6.egg
. 我在
python 3.6
运行它, setuptools==36.2.7
,得到像下面这样的egg文件: dist/demo-0.0.1-py3.6.egg
。 I install this egg file without any errors in python3. 我安装了这个egg文件,在python3中没有任何错误。
But if I want to install this egg file in python 2.7
, I run this: 但是,如果要在
python 2.7
安装此egg文件,请运行以下命令:
source activate py2
easy_install dist/demo-0.0.1-py3.6.egg
I got error like this: 我有这样的错误:
error: Could not find suitable distribution for Requirement.parse('demo==0.0.1')
The best practices nowadays is to use the wheel format (instead of egg) and install with pip. 如今的最佳做法是使用滚轮格式(而不是egg)并使用pip进行安装。
In your virtualenv: 在您的virtualenv中:
pip install wheel
python setup.py bdist_wheel
In your dist
directory you'll a .whl file. 在
dist
目录中,您将创建一个.whl文件。
Then in py2 virtualenv you can do: 然后在py2 virtualenv中,您可以执行以下操作:
pip install your-lib-xyz.whl
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.