0
点赞
收藏
分享

微信扫一扫

入了 macbookpro M1 的坑,果然是很多的坑,碰到就记录


概述

昨晚收到了macbookpro. M1芯片版,知道M1会是个坑,考虑到近苹果的号召力,后续适配应该是没问题的,短期内还能用老air顶一下,电子产品还是买新不买旧,所以还是选了 M1 版。果然有坑,在此记录各种坑和解决办法:

一.日常使用类

1.外接非4k屏,不能开HiDPI

开始以为是 big sur 的问题,后面找了一下相关文章,还是M1的问题。

​​https://github.com/xzhih/one-key-hidpi/issues/164​​

目前暂时没法解决,只能多做做眼保健了,公司显示器2k都不到,惨不忍睹。--20210726

xulong@xulongdeMacBook-Pro ~ % ioreg -l |grep DisplayAttributes
| | | | "DisplayAttributes" = {"ProductAttributes"={}}
| | | | "DisplayAttributes" = {"ProductAttributes"={"ManufacturerID"="AOC","YearOfManufacture"=2018,"SerialNumber"=59438,"ProductName"="24B1W","AlphanumericSerialNumber"="GMXJ5HA059438","LegacyManufacturerID"=1507,"ProductID"=9217,"WeekOfManufacture"=21},"Chromaticity"={"Red"={"X"=42624,"Y"=21824},"Green"={"X"=20864,"Y"=40384},"Blue"={"X"=9728,"Y"=3392}},"DefaultWhitePoint"={"X"=20544,"Y"=21568,"Gamma"=144179},"SupportsStandby"=Yes,"PreciseAspectRatio"=117513,"MaxHorizontalImageSize"=52,"DefaultColorSpaceIsSRGB"=No,"SupportsSuspend"=No,"SupportsActiveOff"=No,"MaxVerticalImageSize"=29,"WhitePoints"=({"X"=20544,"Y"=21568,"Gamma"=144179}),"HasHDMILegacyEDID"=Yes,"NativeFormatVerticalPixels"=1080,"ContinuousFrequencySupport"="None","AspectRatio"=15,"NativeFormatHorizontalPixels"=1920}
xulong@xulongdeMacBook-Pro ~ %



# "ProductName"="24B1W "LegacyManufacturerID"=1507 "ProductID"=9217

二.软件开发类

1. pyinstaller 打包提示 "Bad CPU type in executable"

把原来开发的程序,今天拿出来打包测试,开始也没太注意,没什么错误提示,但是运行打包文件时就出错。

sys.prefix = ''
sys.exec_prefix = ''
sys.path = [
'/var/folders/3f/rpfnhxzj3s14n0kjy352krpm0000gn/T/_MEIuGz6Mk/base_library.zip',
'/var/folders/3f/rpfnhxzj3s14n0kjy352krpm0000gn/T/_MEIuGz6Mk/lib-dynload',
'/var/folders/3f/rpfnhxzj3s14n0kjy352krpm0000gn/T/_MEIuGz6Mk',
]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
LookupError: unknown encoding: utf-8

Current thread 0x0000000101fbfd40 (most recent call first):
<no Python frame>
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.

开始一直以为是有什么模块引入的问题,后面找了很久,都排除了,再重新打包看log,发现一点端倪了:

41 INFO: Caching module graph hooks...
44 INFO: Analyzing base_library.zip ...
arch: posix_spawnp: /Users/xulong/.pyenv/versions/3.9.6/envs/gxtimer/bin/python3.9: Bad CPU type in executable
arch: posix_spawnp: /Users/xulong/.pyenv/versions/3.9.6/envs/gxtimer/bin/python3.9: Bad CPU type in executable
1029 INFO: Processing pre-find module path hook distutils from '/Users/xulong/.pyenv/versions/3.9.6/envs/gxtimer/lib/python3.9/site-packages/PyInstaller/hooks/pre_find_module_path/hook-distutils.py'.
1029 INFO: distutils: retargeting to non-venv dir '/Users/xulong/.pyenv/versions/3.9.6/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9'

入了 macbookpro M1 的坑,果然是很多的坑,碰到就记录_git

有几段提示 "Bad CPU type in executable", 虽然这里只是提示,没报错,但是这个太关键了,找了一下Pyinstaller 相关的帖子,终于到原因了,首先产生上面 错误的地方是,验证了一下

​​https://github.com/pyinstaller/pyinstaller/issues/5438​​

from PyInstaller.utils.hooks import collect_submodules
collect_submodules('encodings')

上面测试代码,在我的 macbook air ( intel cpu) 下面能正常运行, 放是我的macbook pro( M1) 下面运行就报错了:

>>> collect_submodules('wx')
arch: posix_spawnp: /Users/xulong/.pyenv/versions/3.9.6/envs/gxtimer/bin/python: Bad CPU type in executable
['wx']
>>> collect_submodules('encodings')
arch: posix_spawnp: /Users/xulong/.pyenv/versions/3.9.6/envs/gxtimer/bin/python: Bad CPU type in executable
['encodings']
>>>

再找到另一个贴子,说明了pyinstaller 代码中的原因。

​​Bad CPU Type on Apple Silicon · Issue #5640 · pyinstaller/pyinstaller · GitHub​​

目前的解决办法只能是下载最新版 pyinstaller 源码,修改并编译:

入了 macbookpro M1 的坑,果然是很多的坑,碰到就记录_git_02

 重新编译

入了 macbookpro M1 的坑,果然是很多的坑,碰到就记录_git_03

按上面方法安装完,

入了 macbookpro M1 的坑,果然是很多的坑,碰到就记录_开发语言_04

入了 macbookpro M1 的坑,果然是很多的坑,碰到就记录_开发语言_05

入了 macbookpro M1 的坑,果然是很多的坑,碰到就记录_开发语言_06

测试,打包正常,运行也正常。

--20210726 

2.wxFormBuilder 没有针对M1的release版,要自己在M1下编译。

参考:​​https://github.com/wxFormBuilder/wxFormBuilder​​ 

注意点:a. git clone 时比较慢,里面有个组件老下载不成功,可以单独 clone它,多试几次

b. 完全按文档操作,虽然可以正常编译成功,但是并不能运行,运行就报错。 我改成debug版可以运行。

brew install wxmac boost dylibbundler make
git clone --recursive --depth=1 https://github.com/wxFormBuilder/wxFormBuilder
cd wxFormBuilder
./create_build_files4.sh
#前面基本一致。

#因为最新版是3.1所以这里有点不一样
cd build/3.1/gmake
#改成用debug版本(release 版实测不行)
xulong@xulongdeMacBook-Pro gmake % make config=debug

。。。。省略。。。。
dataobject.cpp
cpppanel.cpp
objecttree.cpp
md5.cc
Linking wxFormBuilder
Running post-build commands
sh ../../../install/macosx/postbuild.sh -c debug

#按上而提执行 postbuild.sh

xulong@xulongdeMacBook-Pro gmake % ../../../install/macosx/postbuild.sh -c debug
xulong@xulongdeMacBook-Pro wxFormBuilder % cd ../../../output/
xulong@xulongdeMacBook-Pro output % open wxFormBuilderd.app


#wxgnolux 20210728

举报

相关推荐

0 条评论