2017-08-09 83 views
0

setup.py是这样的:python3 bdist_egg无法在python2中安装?

#!/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"], 
) 

然后我DIST它:

source activate py3 
python setup.py bdist_eg 

python 3.6运行它,setuptools==36.2.7,获得egg文件是这样的:dist/demo-0.0.1-py3.6.egg。我在python3中安装这个egg文件没有任何错误。

但是,如果我想安装这个蛋文件python 2.7,我运行此:

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') 
+0

您正在使用哪个版本的seruptools的为Python 2.7? –

+0

@LaurentLAPORTE'setuptools == 36.2.7' in python2.7。我使用['anaconda'](https://www.continuum.io/downloads) – roger

+0

我建议您使用** pip **而不是** easy_install **。更现代化,可以处理“轮子”格式。 –

回答

1

的最佳做法,现在是使用wheel格式(而不是鸡蛋)并用pip安装。

在你的virtualenv:

pip install wheel 
python setup.py bdist_wheel 

在你dist目录,你会一个.whl文件。

然后在PY2 virtualenv中,你可以这样做:

pip install your-lib-xyz.whl