现在无法在 macOS Big Sur 上使用 setup.py 安装

3 python failed-installation setup.py macos-big-sur

我有 2 个项目在 ubuntu 上安装得很好,都需要 python3.8,都可以使用安装python setup.py install,我偶尔会从虚拟环境中卸载/安装它们,以及出于测试目的全局安装它们。最近,各种麻烦和错误消息开始出现,没有任何特殊事件发生,我有一天刚醒来,尝试安装其中一个,我得到一个错误,然后我尝试另一个并得到另一个错误。我将包含这两个脚本,并展示我在 macOS Big Sur 11.0 上setup.py重现结果的步骤,因为这两个脚本在 Ubuntu 上安装得非常好,并且各自的依赖项列表相同。

版本:

python: 3.8.6
pip:    20.3.1
macOS:  11.0.1
Run Code Online (Sandbox Code Playgroud)

项目一:

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
Run Code Online (Sandbox Code Playgroud)

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',
        ],
    },
)
Run Code Online (Sandbox Code Playgroud)

笔记:

  • 我将根据字符限制截断日志。
  • 下面的尝试是在 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
Run Code Online (Sandbox Code Playgroud)

结果:

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
Run Code Online (Sandbox Code Playgroud)

尝试2:(我使用pip安装pyqt)

pip install pyqt5==5.15.2 # success
python setup.py install # fail
Run Code Online (Sandbox Code Playgroud)

结果:

No module named numpy.
Run Code Online (Sandbox Code Playgroud)

尝试3:(添加setup_requires=['numpy==1.18.5']到setup())

python setup.py install
Run Code Online (Sandbox Code Playgroud)

结果:

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
Run Code Online (Sandbox Code Playgroud)

尝试4:

我检查了这个问题,但没有什么帮助,所以我手动安装 numpy 和 scipy:

pip install numpy==1.18.5 scipy # success
python setup.py install # fail
Run Code Online (Sandbox Code Playgroud)

结果:

ModuleNotFoundError: No module named 'skbuild'
Run Code Online (Sandbox Code Playgroud)

尝试5:

pip install scikit-build==0.11.1 # success
python setup.py install # fail
Run Code Online (Sandbox Code Playgroud)

结果:

error: Setup script exited with Problem with the CMake installation, aborting build. CMake executable is cmake
Run Code Online (Sandbox Code Playgroud)

尝试6:

我在这里检查了这个问题并相应地:

pip install cmake # success
python setup.py install 
Run Code Online (Sandbox Code Playgroud)

Opencv 正在构建,我不确定为什么或什么触发了构建,所以我中止并使用 pip 手动安装 opencv:

pip install opencv-python-headless==4.4.0.46 # success
python setup.py install # fail
Run Code Online (Sandbox Code Playgroud)

结果:

Could not find suitable distribution for Requirement.parse('tensorflow-addons==0.11.2')
Run Code Online (Sandbox Code Playgroud)

尝试7:

pip install tensorflow-addons==0.11.2 # success
python setup.py install 
Run Code Online (Sandbox Code Playgroud)

再次构建 lxml,我不知道如何或为什么,所以我手动安装它并:

pip install lxml==4.6.2 # success
python setup.py install # fail
Run Code Online (Sandbox Code Playgroud)

结果:

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.
Run Code Online (Sandbox Code Playgroud)

尝试8:

pip install matplotlib==3.3.3 # success
python setup.py install # fail
Run Code Online (Sandbox Code Playgroud)

结果:

Could not find suitable distribution for Requirement.parse('tensorflow==2.3.1')
Run Code Online (Sandbox Code Playgroud)

尝试 9:(在之前的尝试中,已经使用 pip 手动安装了超过 75% 的需求)

pip install tensorflow==2.3.1 # success
python setup.py install # fail
Run Code Online (Sandbox Code Playgroud)

结果:(pandas安装失败)

RuntimeError: Cannot cythonize without Cython installed.
Run Code Online (Sandbox Code Playgroud)

尝试10:(我手动安装cython)

pip install cython # success
python setup.py install
Run Code Online (Sandbox Code Playgroud)

由于某种原因,熊猫再次被构建,所以我手动安装它并且列表还在继续......我认为在这个简单的演示之后,我什至不需要复制第二个项目的步骤,但是这是它的要求,我几乎得到了上面所示的相同问题的变体。

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
Run Code Online (Sandbox Code Playgroud)

matplotlib 首先失败,然后是 ta-lib (假设我brew install ta-lib在那之前运行过),并且这个列表还在继续......