Mac上pyenv的安装及使用

Mac上pyenv的安装及使用

安装

brew update

brew install pyenv

报错

复制代码
  git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
  git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask fetch --unshallow

那就执行这2句

还报错

复制代码
git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
remote: Enumerating objects: 365476, done.
remote: Counting objects: 100% (365455/365455), done.
remote: Compressing objects: 100% (147319/147319), done.
fatal: The remote end hung up unexpectedly12 MiB | 9.00 KiB/s     
fatal: early EOF
fatal: index-pack failed

需要换源

参考 https://blog.csdn.net/u013549582/article/details/120887331

复制代码
## 更新 homebrew-cask(如果提示 No such file or directory 可以先跳过前三个命令)
cd "$(brew --repo)"/Library/Taps/homebrew/homebrew-cask
# 更换源
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git 
# 更新
git fetch --unshallow 
 
## 更新 homebrew-core
cd "$(brew --repo)"/Library/Taps/homebrew/homebrew-core
# 更换源
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
# 更新
git fetch --unshallow 

再次执行

brew update

报错

复制代码
==> `brew cleanup` has not been run in 30 days, running now...

需要授权

复制代码
sudo chown -R $(whoami):admin /usr/local/* && sudo chmod -R g+rwx /usr/local/* 

当然这里尽量缩小授权的范围

然后执行

brew install pyenv

终于执行完了

可能需要多执行几次

然后查看版本

pyenv versions

查看可以安装的版本

pyenv install -l

安装

pyenv install 3.8.8

然后报错

复制代码
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LC_ALL = (unset),
        LANG = "en_CN.utf-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew

需要执行

复制代码
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8

然后重新执行pyenv install 3.8.8

还是报错,见鬼了

复制代码
python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
Downloading Python-3.8.8.tar.xz...
-> https://www.python.org/ftp/python/3.8.8/Python-3.8.8.tar.xz
error: failed to download Python-3.8.8.tar.xz

BUILD FAILED (OS X 13.2 using python-build 20180424)

Results logged to /var/folders/jx/k9mhvtg96ggff_8_3c5bvqch0000gn/T/python-build.20240707210526.1843.log

Last 10 log lines:
/var/folders/jx/k9mhvtg96ggff_8_3c5bvqch0000gn/T/python-build.20240707210526.1843 /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
warning: xz not found; consider installing `xz` package
curl: (28) Failed to connect to www.python.org port 443 after 75025 ms: Couldn't connect to server

最后还是放弃了

https://www.python.org/downloads/macos/ 下载一个版本,手动安装,哭死

换了版本之后,

python3 -V

pip3 --version

相关推荐
Bruce_Liuxiaowei8 小时前
Mac与Kali主机间SSH连接故障排除:主机密钥变更的解决方案
运维·macos·网络安全·ssh
2501_938780289 小时前
Objective-C 类的协议(Protocol)应用:解耦父子类与跨类通信实践
开发语言·macos·objective-c
wa的一声哭了10 小时前
Mac os安装Easyconnect卡在正在验证软件包
运维·服务器·git·macos·eclipse·github·mac
Jackson@ML10 小时前
在macOS上搭建C#集成开发环境指南
开发语言·macos·c#
00后程序员张10 小时前
iOS 26 内存占用监控 多工具协同下的性能稳定性分析实战
android·macos·ios·小程序·uni-app·cocoa·iphone
sunshine~~~10 小时前
【笔记】macOs arm架构安装虚拟机Ubuntu环境:ROS2 + Python开发
arm开发·笔记·python·macos·ros2
心灵宝贝10 小时前
Mac版Color Folder v3.8安装教程(附dmg文件安装步骤和搜索关键词)
macos
北冥有鱼被烹11 小时前
【微知】MAC笔记本如何重启tourchbar?(sudo pkill TouchBarServer)
macos
2501_9159090612 小时前
iOS 26 性能监控工具有哪些?多工具协同打造全方位性能分析体系
android·macos·ios·小程序·uni-app·cocoa·iphone
行思理12 小时前
macos 如何清空IntelliJ IDEA安装记录
java·macos·intellij-idea