简体   繁体   English

无法使用 Pyenv 在 macOS Monterey 12.5 上安装 Python 版本

[英]Unable to install Python versions on macOS Monterey 12.5 using Pyenv

Disclaimer : I've read many, many, many threads about this but no solution worked for me, or at least wasn't clear enough in what I would do to my OS.免责声明:我已经阅读了很多很多关于此的主题,但没有解决方案对我有用,或者至少我对我的操作系统的处理不够清楚。

Recently I migrated from an old MacBookPro with Catalina to the M1 Pro with Monterey.最近,我从配备 Catalina 的旧 MacBookPro 迁移到配备 Monterey 的 M1 Pro。 My previous install of Pyenv has been transferred correctly with Time Machine.我之前安装的 Pyenv 已通过 Time Machine 正确传输。

Now I want to create a virtual environment for installing TensorFlow (without Miniforge, as I saw some guides that manage to), with my classic pyenv virtualenv my_python_version my_tensorflow_env .现在我想用我的经典pyenv virtualenv my_python_version my_tensorflow_env创建一个虚拟环境来安装 TensorFlow (没有 Miniforge,因为我看到了一些指南)。

To do so, I read that I need Python 3.8 , but currently, I just have 3.10.4为此,我读到我需要 Python 3.8 ,但目前,我只有 3.10.4

$ pyenv versions
  system
* 3.10.4 (set by /Users/username/.pyenv/version)

When I try to install the version I need I get the following error当我尝试安装我需要的版本时,出现以下错误

$ pyenv install 3.8.0                                                                        
python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
Installing Python-3.8.0...
python-build: use readline from homebrew
python-build: use zlib from xcode sdk

BUILD FAILED (OS X 12.5 using python-build 2.3.0-11-ge676fde9)

Inspect or clean up the working tree at /var/folders/1n/5l6269bd647d957r5df7_hj80000gn/T/python-build.20220818101016.38582
Results logged to /var/folders/1n/5l6269bd647d957r5df7_hj80000gn/T/python-build.20220818101016.38582.log

Last 10 log lines:
checking size of _Bool... 1
checking size of off_t... 8
checking whether to enable large file support... no
checking size of time_t... 8
checking for pthread_t... yes
checking size of pthread_t... 8
checking size of pthread_key_t... 8
checking whether pthread_key_t is compatible with int... no
configure: error: Unexpected output of 'arch' on OSX
make: *** No targets specified and no makefile found.  Stop.

The log file reads as follows日志文件内容如下

/var/folders/1n/5l6269bd647d957r5df7_hj80000gn/T/python-build.20220818101016.38582 ~
/var/folders/1n/5l6269bd647d957r5df7_hj80000gn/T/python-build.20220818101016.38582/Python-3.8.0 /var/folders/1n/5l6269bd647d957r5df7_hj80000gn/T/python-build.20220818101016.38582 ~
checking build system type... arm-apple-darwin21.6.0
checking host system type... arm-apple-darwin21.6.0
checking for python3.8... no
checking for python3... python3
checking for --enable-universalsdk... no
checking for --with-universal-archs... no
checking MACHDEP... "darwin"
checking for gcc... clang
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether clang accepts -g... yes
checking for clang option to accept ISO C89... none needed
checking how to run the C preprocessor... clang -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for a sed that does not truncate output... /usr/local/bin/gsed
checking for --with-cxx-main=<compiler>... no
checking for clang++... no
configure:

  By default, distutils will build C++ extension modules with "clang++".
  If this is not intended, then set CXX on the configure command line.
  
checking for the platform triplet based on compiler characteristics... darwin
checking for -Wl,--no-as-needed... no
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking minix/config.h usability... no
checking minix/config.h presence... no
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking for the Android API level... not Android
checking for --with-suffix... 
checking for case-insensitive build directory... yes
checking LIBRARY... libpython$(VERSION)$(ABIFLAGS).a
checking LINKCC... $(PURIFY) $(MAINCC)
checking for GNU ld... no
checking for --enable-shared... no
checking for --enable-profiling... no
checking LDLIBRARY... libpython$(VERSION)$(ABIFLAGS).a
checking for ar... ar
checking for readelf... no
checking for a BSD-compatible install... /usr/bin/install -c
checking for a thread-safe mkdir -p... ./install-sh -c -d
checking for --with-pydebug... no
checking for --with-trace-refs... no
checking for --with-assertions... no
checking for --enable-optimizations... no
checking PROFILE_TASK... -m test --pgo
checking for --with-lto... no
checking for llvm-profdata... no
configure: llvm-profdata found via xcrun: /usr/bin/xcrun llvm-profdata
checking for -Wextra... yes
checking whether clang accepts and needs -fno-strict-aliasing... no
checking if we can turn off clang unused result warning... yes
checking if we can turn off clang unused parameter warning... yes
checking if we can turn off clang missing field initializers warning... yes
checking if we can turn on clang mixed sign comparison warning... yes
checking if we can turn on clang unreachable code warning... yes
checking if we can turn on clang strict-prototypes warning... yes
checking if we can make implicit function declaration an error in clang... yes
checking which MACOSX_DEPLOYMENT_TARGET to use... 12.5
checking whether pthreads are available without options... yes
checking whether clang++ also accepts flags for thread support... no
checking for ANSI C header files... (cached) yes
checking asm/types.h usability... no
checking asm/types.h presence... no
checking for asm/types.h... no
checking crypt.h usability... no
checking crypt.h presence... no
checking for crypt.h... no
checking conio.h usability... no
checking conio.h presence... no
checking for conio.h... no
checking direct.h usability... no
checking direct.h presence... no
checking for direct.h... no
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking errno.h usability... yes
checking errno.h presence... yes
checking for errno.h... yes
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking grp.h usability... yes
checking grp.h presence... yes
checking for grp.h... yes
checking ieeefp.h usability... no
checking ieeefp.h presence... no
checking for ieeefp.h... no
checking io.h usability... no
checking io.h presence... no
checking for io.h... no
checking langinfo.h usability... yes
checking langinfo.h presence... yes
checking for langinfo.h... yes
checking libintl.h usability... yes
checking libintl.h presence... yes
checking for libintl.h... yes
checking process.h usability... no
checking process.h presence... no
checking for process.h... no
checking pthread.h usability... yes
checking pthread.h presence... yes
checking for pthread.h... yes
checking sched.h usability... yes
checking sched.h presence... yes
checking for sched.h... yes
checking shadow.h usability... no
checking shadow.h presence... no
checking for shadow.h... no
checking signal.h usability... yes
checking signal.h presence... yes
checking for signal.h... yes
checking stropts.h usability... no
checking stropts.h presence... no
checking for stropts.h... no
checking termios.h usability... yes
checking termios.h presence... yes
checking for termios.h... yes
checking utime.h usability... yes
checking utime.h presence... yes
checking for utime.h... yes
checking poll.h usability... yes
checking poll.h presence... yes
checking for poll.h... yes
checking sys/devpoll.h usability... no
checking sys/devpoll.h presence... no
checking for sys/devpoll.h... no
checking sys/epoll.h usability... no
checking sys/epoll.h presence... no
checking for sys/epoll.h... no
checking sys/poll.h usability... yes
checking sys/poll.h presence... yes
checking for sys/poll.h... yes
checking sys/audioio.h usability... no
checking sys/audioio.h presence... no
checking for sys/audioio.h... no
checking sys/xattr.h usability... yes
checking sys/xattr.h presence... yes
checking for sys/xattr.h... yes
checking sys/bsdtty.h usability... no
checking sys/bsdtty.h presence... no
checking for sys/bsdtty.h... no
checking sys/event.h usability... yes
checking sys/event.h presence... yes
checking for sys/event.h... yes
checking sys/file.h usability... yes
checking sys/file.h presence... yes
checking for sys/file.h... yes
checking sys/ioctl.h usability... yes
checking sys/ioctl.h presence... yes
checking for sys/ioctl.h... yes
checking sys/kern_control.h usability... yes
checking sys/kern_control.h presence... yes
checking for sys/kern_control.h... yes
checking sys/loadavg.h usability... no
checking sys/loadavg.h presence... no
checking for sys/loadavg.h... no
checking sys/lock.h usability... yes
checking sys/lock.h presence... yes
checking for sys/lock.h... yes
checking sys/mkdev.h usability... no
checking sys/mkdev.h presence... no
checking for sys/mkdev.h... no
checking sys/modem.h usability... no
checking sys/modem.h presence... no
checking for sys/modem.h... no
checking sys/param.h usability... yes
checking sys/param.h presence... yes
checking for sys/param.h... yes
checking sys/random.h usability... yes
checking sys/random.h presence... yes
checking for sys/random.h... yes
checking sys/select.h usability... yes
checking sys/select.h presence... yes
checking for sys/select.h... yes
checking sys/sendfile.h usability... no
checking sys/sendfile.h presence... no
checking for sys/sendfile.h... no
checking sys/socket.h usability... yes
checking sys/socket.h presence... yes
checking for sys/socket.h... yes
checking sys/statvfs.h usability... yes
checking sys/statvfs.h presence... yes
checking for sys/statvfs.h... yes
checking for sys/stat.h... (cached) yes
checking sys/syscall.h usability... yes
checking sys/syscall.h presence... yes
checking for sys/syscall.h... yes
checking sys/sys_domain.h usability... yes
checking sys/sys_domain.h presence... yes
checking for sys/sys_domain.h... yes
checking sys/termio.h usability... no
checking sys/termio.h presence... no
checking for sys/termio.h... no
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking sys/times.h usability... yes
checking sys/times.h presence... yes
checking for sys/times.h... yes
checking for sys/types.h... (cached) yes
checking sys/uio.h usability... yes
checking sys/uio.h presence... yes
checking for sys/uio.h... yes
checking sys/un.h usability... yes
checking sys/un.h presence... yes
checking for sys/un.h... yes
checking sys/utsname.h usability... yes
checking sys/utsname.h presence... yes
checking for sys/utsname.h... yes
checking sys/wait.h usability... yes
checking sys/wait.h presence... yes
checking for sys/wait.h... yes
checking pty.h usability... no
checking pty.h presence... no
checking for pty.h... no
checking libutil.h usability... no
checking libutil.h presence... no
checking for libutil.h... no
checking sys/resource.h usability... yes
checking sys/resource.h presence... yes
checking for sys/resource.h... yes
checking netpacket/packet.h usability... no
checking netpacket/packet.h presence... no
checking for netpacket/packet.h... no
checking sysexits.h usability... yes
checking sysexits.h presence... yes
checking for sysexits.h... yes
checking bluetooth.h usability... no
checking bluetooth.h presence... no
checking for bluetooth.h... no
checking linux/tipc.h usability... no
checking linux/tipc.h presence... no
checking for linux/tipc.h... no
checking linux/random.h usability... no
checking linux/random.h presence... no
checking for linux/random.h... no
checking spawn.h usability... yes
checking spawn.h presence... yes
checking for spawn.h... yes
checking util.h usability... yes
checking util.h presence... yes
checking for util.h... yes
checking alloca.h usability... yes
checking alloca.h presence... yes
checking for alloca.h... yes
checking endian.h usability... no
checking endian.h presence... no
checking for endian.h... no
checking sys/endian.h usability... no
checking sys/endian.h presence... no
checking for sys/endian.h... no
checking sys/sysmacros.h usability... no
checking sys/sysmacros.h presence... no
checking for sys/sysmacros.h... no
checking linux/memfd.h usability... no
checking linux/memfd.h presence... no
checking for linux/memfd.h... no
checking sys/memfd.h usability... no
checking sys/memfd.h presence... no
checking for sys/memfd.h... no
checking sys/mman.h usability... yes
checking sys/mman.h presence... yes
checking for sys/mman.h... yes
checking for dirent.h that defines DIR... yes
checking for library containing opendir... none required
checking whether sys/types.h defines makedev... yes
checking bluetooth/bluetooth.h usability... no
checking bluetooth/bluetooth.h presence... no
checking for bluetooth/bluetooth.h... no
checking for net/if.h... yes
checking for linux/netlink.h... no
checking for linux/qrtr.h... no
checking for linux/vm_sockets.h... no
checking for linux/can.h... no
checking for linux/can/raw.h... no
checking for linux/can/bcm.h... no
checking for clock_t in time.h... yes
checking for makedev... yes
checking for le64toh... no
checking for mode_t... yes
checking for off_t... yes
checking for pid_t... yes
checking for size_t... yes
checking for uid_t in sys/types.h... yes
checking for ssize_t... yes
checking for __uint128_t... yes
checking size of int... 4
checking size of long... 8
checking size of long long... 8
checking size of void *... 8
checking size of short... 2
checking size of float... 4
checking size of double... 8
checking size of fpos_t... 8
checking size of size_t... 8
checking size of pid_t... 4
checking size of uintptr_t... 8
checking for long double... yes
checking size of long double... 8
checking size of _Bool... 1
checking size of off_t... 8
checking whether to enable large file support... no
checking size of time_t... 8
checking for pthread_t... yes
checking size of pthread_t... 8
checking size of pthread_key_t... 8
checking whether pthread_key_t is compatible with int... no
configure: error: Unexpected output of 'arch' on OSX
make: *** No targets specified and no makefile found.  Stop.
  • Xcode Version 13.2 (13C90) with Command Line Tools just installed after downloading such version of Xcode Xcode 版本 13.2 (13C90),在下载 Xcode 的此类版本后刚刚安装了命令行工具
  • macOS Monterey 12.5 macOS 蒙特雷 12.5
  • $ brew list --versions pyenv produces pyenv 2.3.3 $ brew list --versions pyenv产生pyenv 2.3.3

Can you suggest some meaningful solution that doesn't break everything and allows me to properly use both TensorFlow and Pyenv as they are supposed to?您能否建议一些有意义的解决方案,它不会破坏一切,并允许我按照应有的方式正确使用 TensorFlow 和 Pyenv? Without tying my system to some unknown conditions or settings which I might break in the future.无需将我的系统与将来可能会破坏的某些未知条件或设置联系起来。

Ok finally found the solution: the problem was that I had recently migrated from Catalina on an old MBP2013 (Intel) to this new M1.好的,终于找到了解决方案:问题是我最近从旧 MBP2013(英特尔)上的 Catalina 迁移到了这个新的 M1。 The Homebrew installation was "faulty" due to this, so I reinstalled brew from zero and everything works fine now.由于这个原因,Homebrew 安装是“错误的”,所以我从零重新安装了 brew,现在一切正常。

Bonus tip: I managed to install TensorFlow without Conda by running额外提示:我设法通过运行在没有 Conda 的情况下安装 TensorFlow

pip install tensorflow-macos
pip install tensorflow-metal

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM