Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/364.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
python3 bdist_egg无法安装在python2中?_Python_Setuptools_Egg - Fatal编程技术网

python3 bdist_egg无法安装在python2中?

python3 bdist_egg无法安装在python2中?,python,setuptools,egg,Python,Setuptools,Egg,我的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"], ) error: Could not find

我的
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"],
)
error: Could not find suitable distribution for Requirement.parse('demo==0.0.1')
然后我把它分开:

source activate py3
python setup.py bdist_eg
我在
python3.6
中运行它,
setuptools==36.2.7
,得到如下egg文件:
dist/demo-0.0.1-py3.6.egg
。我在python3中安装了这个egg文件,没有任何错误

但是如果我想在python 2.7中安装这个egg文件,我会运行以下命令:

source activate py2
easy_install dist/demo-0.0.1-py3.6.egg
我得到了这样的错误:

#!/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"],
)
error: Could not find suitable distribution for Requirement.parse('demo==0.0.1')

现在的最佳实践是使用格式(而不是egg)并使用pip安装

在您的虚拟视频中:

pip install wheel
python setup.py bdist_wheel
dist
目录中,您将看到一个.whl文件

然后在py2 virtualenv中,您可以执行以下操作:

pip install your-lib-xyz.whl

您在python2.7中使用哪个版本的seruptools?@LaurentPorte
setuptools==36.2.7
。我建议您使用pip而不是简易安装。更现代,可以处理“轮子”格式。@LaurentPorte但如何使用
pip
安装本地egg文件?另外,
easy\u install
setuptools
本身提供,它应该可以工作。如果您有最新版本的pip,您可以安装“egg”文件。或者,升级它:
pip安装——升级pip