【发布时间】:2020-12-03 16:13:45
【问题描述】:
我有 2 个项目在 ubuntu 上安装得非常好,都需要 python3.8,都可以使用 python setup.py install 安装,我偶尔会从/到虚拟环境以及全局卸载/安装它们以进行测试。最近开始出现各种故障和错误消息,没有任何特殊事件,我一天醒来,尝试安装其中一个,我得到一个错误,然后我尝试另一个,又得到另一个错误。我将包含两个 setup.py 脚本并展示我在在 macOS Big Sur 11.0 上遵循的步骤以重现结果,因为它们都可以在具有相同依赖项列表的 Ubuntu 上完美安装。
版本:
python: 3.8.6
pip: 20.3.1
macOS: 11.0.1
项目 1:
requirements.txt
imagesize==1.2.0
numpy==1.18.5
pandas==1.1.4
seaborn==0.11.0
tensorflow==2.3.1
matplotlib==3.3.3
lxml==4.6.2
imgaug==0.4.0
tensorflow-addons==0.11.2
opencv-python-headless==4.4.0.46
imagecorruptions==1.1.2
configparser~=5.0.1
scipy==1.5.4
PyQt5==5.15.2
tabulate==0.8.7
ipykernel==5.3.4
setup.py
from setuptools import setup, find_packages
install_requires = [dep.strip() for dep in open('requirements.txt')]
setup(
name='project1',
version='1.0',
packages=find_packages(),
url='url',
license='MIT',
author='author',
author_email='email@domain',
description='description goes here',
install_requires=install_requires,
python_requires='>=3.8',
entry_points={
'console_scripts': [
'some_entry_point',
],
},
)
注意事项:
- 我将截断日志以限制字符数。
- 以下尝试是在 virtualenv 中完成的
- 只要用
pip install -r requirements就不会出现各种问题 - 安装在 Ubuntu 上运行良好,过去在 macOS 上运行良好,即使在我升级到 Big Sur 之后,它突然决定不再运行。
- python 是使用
brew install python@3.8安装的
尝试 1:
virtualenv proj1
source proj1/bin/activate
python setup.py install
结果:
Searching for PyQt5==5.15.2
Reading https://pypi.org/simple/PyQt5/
Downloading https://files.pythonhosted.org/packages/28/6c/640e3f5c734c296a7193079a86842a789edb7988dca39eab44579088a1d1/PyQt5-5.15.2.tar.gz#sha256=372b08dc9321d1201e4690182697c5e7ffb2e0770e6b4a45519025134b12e4fc
Best match: PyQt5 5.15.2
Processing PyQt5-5.15.2.tar.gz
error: Couldn't find a setup script in /var/folders/hr/61r_7jcx2r3cnklwrr2zwbqw0000gn/T/easy_install-sl9y34mj/PyQt5-5.15.2.tar.gz
尝试2:(我使用pip安装pyqt)
pip install pyqt5==5.15.2 # success
python setup.py install # fail
结果:
No module named numpy.
尝试3:(将setup_requires=['numpy==1.18.5']添加到setup())
python setup.py install
结果:
numpy.distutils.system_info.NotFoundError: No lapack/blas resources found. Note: Accelerate is no longer supported.
During handling of the above exception, another exception occurred:
# Traceback goes here
RuntimeError: implement_array_function method already has a docstring
尝试 4:
我检查了这个 issue 并没有任何帮助,所以我手动安装了 numpy 和 scipy:
pip install numpy==1.18.5 scipy # success
python setup.py install # fail
结果:
ModuleNotFoundError: No module named 'skbuild'
尝试 5:
pip install scikit-build==0.11.1 # success
python setup.py install # fail
结果:
error: Setup script exited with Problem with the CMake installation, aborting build. CMake executable is cmake
尝试 6:
我检查了问题here 并相应地:
pip install cmake # success
python setup.py install
Opencv 正在构建中,我不确定为什么或什么触发了构建,所以我中止并使用 pip 手动安装了 opencv:
pip install opencv-python-headless==4.4.0.46 # success
python setup.py install # fail
结果:
Could not find suitable distribution for Requirement.parse('tensorflow-addons==0.11.2')
尝试 7:
pip install tensorflow-addons==0.11.2 # success
python setup.py install
再次构建lxml,我不知道如何或为什么,所以我手动安装它并且:
pip install lxml==4.6.2 # success
python setup.py install # fail
结果:
Running matplotlib-3.3.3/setup.py -q bdist_egg --dist-dir /var/folders/hr/61r_7jcx2r3cnklwrr2zwbqw0000gn/T/easy_install-q32mufo3/matplotlib-3.3.3/egg-dist-tmp-_js7sem9
UPDATING build/lib.macosx-11.0-x86_64-3.8/matplotlib/_version.py
set build/lib.macosx-11.0-x86_64-3.8/matplotlib/_version.py to '3.3.3'
error: Setup script exited with error: Failed to download FreeType. Please download one of ['https://downloads.sourceforge.net/project/freetype/freetype2/2.6.1/freetype-2.6.1.tar.gz', 'https://download.savannah.gnu.org/releases/freetype/freetype-2.6.1.tar.gz'] and extract it into build/freetype-2.6.1 at the top-level of the source repository.
尝试 8:
pip install matplotlib==3.3.3 # success
python setup.py install # fail
结果:
Could not find suitable distribution for Requirement.parse('tensorflow==2.3.1')
尝试 9:(在之前的尝试中已经使用 pip 手动安装了超过 75% 的需求)
pip install tensorflow==2.3.1 # success
python setup.py install # fail
结果:(pandas 安装失败)
RuntimeError: Cannot cythonize without Cython installed.
尝试10:(我手动安装cython)
pip install cython # success
python setup.py install
再次出于某种原因正在构建熊猫,所以我手动安装它并且列表继续...... 我想在这个简单的演示之后,我什至不需要复制第二个项目的步骤,但是这里是它的要求,我几乎得到了上面显示的相同问题的变体。
requirements.txt 用于项目2
oauth2client==4.1.3
gcloud==0.18.3
pyarrow==2.0.0
requests==2.24.0
pandas==1.1.4
httplib2==0.15.0
TA-Lib==0.4.19
matplotlib==3.3.2
matplotlib 首先失败,然后是 ta-lib(假设我在此之前运行了 brew install ta-lib),然后列表继续......
【问题讨论】:
-
很多。如果可能的话,如果您可以提供一个最小的可重现示例,那将会很有帮助,但在您的情况下,这可能是不可能的。 - 首先,我怀疑这个设置是否曾经在 mac os 11 上运行过。它相当新,可能很多库还不兼容,或者至少没有这个 OS 的轮子。 -- 第二件事,我也怀疑
python setup.py install是否能够安装不是基于 sdist 的 setuptools 的依赖项,在您的情况下,这可以解释大多数故障。 -- 真的只要使用python -m pip install ...。 -
@sinoroc 实际上是一个最小的可重现示例,如果你有很大的 sur,你可以在
virtualenv中运行setup.py,你自己很可能会看到各种麻烦。它在 macos big sur 上运行得非常好,它在具有相同依赖项的 ubuntu 上运行,虽然我无法证明这一点,但我认为它在 python 3.8.6.2 更新后开始发生,我不确定。关于pip install,您的意思是有一种方法可以使用pip安装setup.py? -
代替
python setup.py install做python -m pip install .-- 代替python setup.py develop做pip install --editable .
标签: python setup.py failed-installation macos-big-sur