我一直在使用openssl和brewpython@2问题,这里已经解释过了(未解决)。重新安装Python和openssl的文档解决方法不起作用,所以我决定卸载并重新安装Python。
问题是,当您尝试使用brew安装Python 2时,您会收到以下消息:
brew install python@2
Error: No available formula with the name "python@2"
==> Searching for a previously deleted formula (in the last month)...
Warning: homebrew/core is shallow clone. To get complete history run:
git -C "$(brew --repo homebrew/core)" fetch --unshallow
python@2 was deleted from homebrew/core in commit 028f11f9e:
python@2: delete (https://github.com/Homebrew/homebrew-core/issues/49796)
EOL 1 January 2020.
We gave it 1 month more to live so that people had time to migrate.
All in all, developers had 11 years to do their migration.
You can use the `brew extract` command and maintain python@2 in your own
tap if necessary:
https://docs.brew.sh/How-to-Create-and-Maintain-a-Tap
To show the formula before removal run:
git -C "$(brew --repo homebrew/core)" show 028f11f9e^:Formula/python@2.rb
If you still use this formula consider creating your own tap:
https://docs.brew.sh/How-to-Create-and-Maintain-a-Tap
不幸的是,我仍然有许多取决于Brew python@2的酿造配方。这些包括例如,
莱森地堡
,公关
aws
zsh: /usr/local/bin/aws: bad interpreter: /usr/local/opt/python@2/bin/python2.7: no such file or directory
我不知道如何使用他们记录的这个< code>brew extract命令来重新安装Python@2。它需要一个公式和一个龙头。我想公式应该是< code>python@2。我不知道水龙头需要什么。
此外,重新安装诸如aws
或letsencrypt
之类的分接头也没有很好的效果。
重新安装 awscli
(酿造重新安装 awscli
) 后,运行 aws 命令仍会出现错误。
aws
/usr/local/Cellar/awscli/2.0.0/libexec/lib/python3.8/site-packages/jmespath/visitor.py:32: SyntaxWarning: "is" with a literal. Did you mean "=="?
if x is 0 or x is 1:
/usr/local/Cellar/awscli/2.0.0/libexec/lib/python3.8/site-packages/jmespath/visitor.py:32: SyntaxWarning: "is" with a literal. Did you mean "=="?
if x is 0 or x is 1:
/usr/local/Cellar/awscli/2.0.0/libexec/lib/python3.8/site-packages/jmespath/visitor.py:34: SyntaxWarning: "is" with a literal. Did you mean "=="?
elif y is 0 or y is 1:
/usr/local/Cellar/awscli/2.0.0/libexec/lib/python3.8/site-packages/jmespath/visitor.py:34: SyntaxWarning: "is" with a literal. Did you mean "=="?
elif y is 0 or y is 1:
/usr/local/Cellar/awscli/2.0.0/libexec/lib/python3.8/site-packages/jmespath/visitor.py:260: SyntaxWarning: "is" with a literal. Did you mean "=="?
if original_result is 0:
usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:
aws help
aws <command> help
aws <command> <subcommand> help
aws: error: the following arguments are required: command
对于那些在苹果公司在macOS 12.3中移除系统python后出现在这里的人来说,这里是如何安装和运行python2和python3的。
Python 2
python
,python2
-
# Download/run the legacy macOS installer (pick which one for your sys)
https://www.python.org/downloads/release/python-2716/
# Add pip for python2.7
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip2.py
python2 get-pip2.py
# Optionally check for pip updates (in case of post-eol patches)
python2 -m pip install --upgrade pip
# Optionally add the helpers like easy_install back onto your path
# In your ~/.zprofile or whatever bash/shell profile equivalent
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH
# Optionally add some helpers while editing shell profile
alias pip2="python2 -m pip"
alias venv2="virtualenv -p python2"
alias venv3="virtualenv -p python3"
# Optionally some apple-specific std libraries are missing, search
# and download them. Example: plistlib.py
curl https://raw.githubusercontent.com/python/cpython/2.7/Lib/plistlib.py -o /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py
# Lastly, there is no symlink /usr/bin/python anymore
# /usr/bin is system protected so you can't add one either
#
# Change your programs to use /usr/local/bin/python
# or google how to disable macOS SIP to make a symlink in /usr/bin
Python三
python3
-
brew update
brew install python3
# Add pip for python 3 in case it is missing
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py
# Check for pip updates
python3 -m pip install --upgrade pip
# Optionally add a helper in ~/.zprofile
alias venv3="virtualenv -p python3"
测试一下
~ % python --version
Python 2.7.16
~ % python2 --version
Python 2.7.16
~ % python3 --version
Python 3.9.10
# Running older python2
python2 -m pip install...
python2 ...
# Testing the venv2 alias from above
venv2 foo
source foo/bin/activate
pip -V # pip 20... from... python2.7
pip install -y -r req.txt
pip uninstall -y -r req.txt
pip freeze
deactivate
# Testing the venv3 alias from above
venv3 foo3
source foo3/bin/activate
pip -V # pip22... from ...python3.9
pip install -y -r req.txt
pip uninstall -y -r req.txt
pip freeze
deactivate
通过卸载/重新安装进行故障排除
# Credit to https://www.macupdate.com/app/mac/5880/python/uninstall
# for many of the tips in this section.
# Sometimes there are problems related to accepting xcode
# tool agreement. Open XCode to make sure it finished
# installing its tool updates.
# Remove old python Application installs
# open the apps dir and delete Python 2, 3 via Finder
open /Applications
# Remove old brew installs
brew list | grep python
brew uninstall python
brew uninstall python3
# find/remove lingering unlinked kegs
ls /usr/local/Cellar/ | grep python
# Cleanup binaries
sudo rm -rf /Library/Frameworks/Pyth*
rm /usr/local/bin/pip*
# Cleanup symlinks
which -a python # check results, and rm each one
which -a python2 # check results, and rm each one
which -a python3 # check results, and rm each one
brew cleanup # prunes symlinks
看来家酿的工作人员真的是让在macOS上使用Python 2.7尽可能的难。
brew提取物
链接真的没有帮助,你需要在这里寻找关于如何从提取的来源中进行自己的点击的答案。brew提取
命令甚至无法正常工作,因为包名中有@。解决方案非常简单,您只需要下载最新的提交文件并从该文件进行安装:
cd ~
wget https://raw.githubusercontent.com/Homebrew/homebrew-core/86a44a0a552c673a05f11018459c9f5faae3becc/Formula/python@2.rb
brew install python@2.rb
rm python@2.rb
可能会有一个关于这是“不稳定”的警告,我不理解为Git历史中的提交是你能得到的最稳定的。
您可以使用pyenv
安装python:
brew install pyenv
pyenv install 2.7.18
(可选)将其设置为全局默认值:
pyenv global 2.7.18
关于为什么使用pyenv
比使用brew
来管理python安装的好文章。
要使python
二进制文件在全球可用,请将垫片添加到PATH:
PATH=$(pyenv root)/shims:$PATH
问题内容: 。已记录的重新安装Python和openssl的解决方法不起作用,因此我决定卸载并重新安装Python。 问题是,当您尝试通过brew安装Python 2时,会收到以下消息: 不幸的是,我仍然有许多取决于Brew的python @ 2的brew公式。这些包括,,PR例如 我不知道如何使用他们记录的命令重新安装Python @ 2。它需要一个公式和一个水龙头。我想公式会是。我不确定水龙头
问题内容: 我想知道是否可以在不离开IPython shell的情况下安装python软件包。 问题答案: 您可以使用以下前缀: 该前缀是一个短手的命令运行shell命令。 您还可以使用前缀,该前缀是命令的简写形式,用于执行shell命令并捕获其输出(默认情况下保存到变量中)。
安装Anaconda后,“~/anaconda/bin”被添加到$PATH变量中。但是现在,我无法运行“brew”: 只有当我在$PATH的开头添加“usr/local/bin: usr/local/sbin”时,我才能让brew工作,但我没有安装Anaconda python。 我怎样才能有一个默认的蟒蛇和可操作的自制啤酒?
技能等级:初学者 我正在尝试在Python中添加一个库。延伸部分是车轮。 有人能告诉安装车轮文件的分步方法吗?
我刚刚安装了Python3.5。1在win7操作系统上,该操作系统也具有python 2.7。在Powershell中键入“python”将启动3.5。1.之前推出了2.7。 现在如何启动python 2.7?键入“python27”或“python27”、“python2.7”、“python2.7”都不行。我有“C:\Python在我的用户环境变量中。 阅读以下讨论后:Powershell中的
如何在随后的绘图中重用中的绘图行? 我想在4个轴上绘制图,每个轴上的前三个单独的图,最后一个轴上的所有3个图。代码如下: 现在打印ax1上的线1、ax2上的线2、ax3上的线3和ax4上的线4。