Mac M1重装环境问题汇总
2022年8月10日 - 由Bo 0 评论 3717 阅读
换了Mac M1, 但是在装包配工作环境时,发现了和以前老Mac不一样的环境问题,于是汇总记录一下:
- 为labelimg安装python包时报错subprocess-exited-with-error, 类似下面的:
error: subprocess-exited-with-error
× Preparing metadata (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [29 lines of output]
Traceback (most recent call last):
File "./venv/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 156, in prepare_metadata_for_build_wheel
hook = backend.prepare_metadata_for_build_wheel
AttributeError: module 'sipbuild.api' has no attribute 'prepare_metadata_for_build_wheel'
这是PyQt5相关的问题,git pull最新,然后切换到分支pyside6,重新安装依赖。
pip install pyside6 lxml
make pyside6
python labelImg.py
- fasttext也报错subprocess-exited-with-error, the default C headers that are shipping with XCode are causing a definition conflict
sudo mv /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include_tmp
pip install fasttext
sudo mv /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include_tmp /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
- paddleocr和opencv-contrib-python的问题
paddleocr目前是2.5.0.3的版本,但是在m1上安装有问题,因为opencv-contrib-python的版本限制到了4.4.0.46,但要4.6.0.66才能被安装上。于是去pypi上下载对应的whl文件,编辑requirement里的opencv-contrib-python的版本;或者去github上clone代码,然后再修改requirement后打包;
我用了第一种,在pypi上找到了paddleocr的2.5.0.3的包,然后下载到本地,接着解压、修改和恢复打包,再用修改后的包进行安装:
wheel unpack paddleocr-2.5.0.3-py3-none-any-origin.whl
# go to folder: paddleocr-2.5.0.3
# modify METADATA file, update the version of opencv-contrib-python to 4.6.0.66
wheel pack paddleocr-2.5.0.3/
- pymssql的python包装不上,得到的错误也是类似“subprocess-exited-with-error”,执行下面的命令就好了
brew install freetds openssl
export LDFLAGS="-L/opt/homebrew/opt/freetds/lib -L/opt/homebrew/opt/openssl@3/lib"
export CFLAGS="-I/opt/homebrew/opt/freetds/include"
export CPPFLAGS="-I/opt/homebrew/opt/openssl@3/include"
python -m pip install pymssql
- pyodbc的python包装不上,得到的错误也是类似“subprocess-exited-with-error”,执行下面的命令就好了
brew list unixodbc
export LDFLAGS="-L/opt/homebrew/Cellar/unixodbc/2.3.11/lib"
export CPPFLAGS="-I/opt/homebrew/Cellar/unixodbc/2.3.11/include"
pip install pyodbc
- pandas装不上老版本比如1.3.0,报错类似Package would be ignored
pip install numpy
pip install cython
pip install --no-use-pep517 pandas==1.3.0
- ruby的tiny_tds安装不上,用如下命令安装
brew install freetds
gem install tiny_tds -- --with-freetds-include=/opt/homebrew/include --with-freetds-lib=/opt/homebrew/lib
gem install eventmachine -- --with-openssl-dir=/opt/homebrew/opt/openssl@1.1
- ruby的bson_ext安装不上,用如下命令安装
gem install bson_ext -- --with-cflags="-Wno-error=implicit-function-declaration"