2017-08-09 118 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