简体   繁体   English

如何在 Mac 上更改 WING 101 上的 python 版本?

[英]How to change python's version on WING 101 on a Mac?

I am currently working on a project with python 3.8.6.我目前正在使用 python 3.8.6 进行项目。 However, I want to change python's version that I am using to 3.5.3.但是,我想将我正在使用的 python 版本更改为 3.5.3。 How can I do this?我怎样才能做到这一点? I'm on a Mac.我在 Mac 上。

I have tried installing python 3.5.3 with the installer from the python downloads website but after it installs and I run python3.5 on my shell, it says我尝试使用 python 下载网站上的安装程序安装 python 3.5.3,但在安装后我在 shell 上运行 python3.5,它说

zsh: killed     python3.5

If I run python3.8 on the shell, it works, but I want the 3.5 version so I can then get the sys.executable to then change the path in Wing.如果我在python3.8上运行 python3.8,它可以工作,但我想要 3.5 版本,所以我可以获取sys.executable ,然后更改 Wing 中的路径。

I've also tried pyenv with homebrew but it fails when it tries to install.我也用自制软件尝试过 pyenv,但它在尝试安装时失败了。 It says它说

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

What can I do?我能做些什么?

You can try using Conda.您可以尝试使用 Conda。 Installation: https://docs.conda.io/projects/conda/en/latest/user-guide/install/macos.html安装: https://docs.conda.io/projects/conda/en/latest/user-guide/install/macos.html

To create environments and switch between them:要创建环境并在它们之间切换:

conda create -n 3.5.3 python=3.5.3
conda activate 3.5.3
conda env list

Support for macOS 11 is still an open issue for pyenv.对 macOS 11 的支持对于 pyenv 来说仍然是一个悬而未决的问题 It's also been asked about before here on Stack Overflow, though due to installing a different Python version, this might not be 100% a duplicate. 之前在 Stack Overflow 上也有人问过这个问题,尽管由于安装了不同的 Python 版本,这可能不是 100% 重复的。

One solution that seems to be working for people is that posted in this blog post :似乎对人们有用的一种解决方案是发布在此博客文章中:

Step 1 Align command-line tools步骤 1 对齐命令行工具

  • Open Xcode-beta.app打开 Xcode-beta.app
  • Go to Preference > Locations Go 至首选项 > 位置
  • Select the right version of command-line tools Select 正确版本的命令行工具

Step 2 Install python步骤 2 安装 python

In this case, I installed 3.8.0.在这种情况下,我安装了 3.8.0。 If you want to install a different version, you will need to change the version in the following command.如果要安装不同的版本,则需要在以下命令中更改版本。

 CFLAGS="-I$(brew --prefix openssl)/include -I$(brew --prefix bzip2)/include -I$(brew --prefix readline)/include -I$(xcrun --show-sdk-path)/usr/include" LDFLAGS="-L$(brew --prefix openssl)/lib -L$(brew --prefix readline)/lib -L$(brew --prefix zlib)/lib -L$(brew --prefix bzip2)/lib" pyenv install --patch 3.8.0 < <(curl -sSL https://github.com/python/cpython/commit/8ea6353.patch\?full_index\=1)

You may also need to make sure you have the following installed:您可能还需要确保已安装以下内容:

brew install zlib bzip2

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

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