Python 3 从计算机上消失了 - MacOS
Python 3 disappeared from computer - MacOS
我在 OS Mojave 上,刚刚使用自制软件安装 geos
和 proj
,python3 消失了。我有两个版本,现在我只有 2.7 版本。我做了 brew install python3
,它说它已经安装但没有链接,然后我按照它的建议做了 brew link python
,但它返回了一个 Error: Could not symlink Frameworks/Python.framework/Headers Target /usr/local/Frameworks/Python.framework/Headers is a symlink belonging to python@2.
。
我怎样才能回到拥有两个版本的状态?。我不是 100% 安装 geos
,proj
是造成它的原因,但我 3 天前使用了 python3。自上次使用 python3.
以来,我还通过自制软件安装了 phantomjs
我需要安装 python 的两个版本。由于我的计算机上似乎还有所有文件,因此处理此问题的适当方法是什么?
提前致谢!
安装虚拟环境,以便您可以使用许多不同版本的 Python。
使用 anaconda python 更适合 python 的发行版。
使用$ type python
查看它指向的位置。使用 brew info
命令列出已安装 python 的信息。
$ brew info python
python: stable 3.7.6 (bottled), HEAD
Interpreted, interactive, object-oriented programming language
https://www.python.org/
/usr/local/Cellar/python/3.7.5 (4,032 files, 61.8MB) *
Poured from bottle on 2019-11-04 at 22:34:01
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/python.rb
==> Dependencies
Build: pkg-config ✔
Required: gdbm ✔, openssl@1.1 ✔, readline ✔, sqlite ✔, xz ✔
==> Options
--HEAD
Install HEAD version
==> Caveats
Python has been installed as
/usr/local/bin/python3
Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, have been installed into
/usr/local/opt/python/libexec/bin
If you need Homebrew's Python 2.7 run
brew install python@2
You can install Python packages with
pip3 install <package>
They will install into the site-package directory
/usr/local/lib/python3.7/site-packages
See: https://docs.brew.sh/Homebrew-and-Python
查看 Caveats
下的行
Python has been installed as
/usr/local/bin/python3
那是您的 python3 别名路径。您可以安全地符号链接 python
以在 ~/.bash_profile
中指向它
$ echo 'alias python=/usr/local/bin/python' > ~/.bash_profile
$ cat ~/.bash_profile
###########################
# you'll probably see these kind of lines before your alias
###########################
export PATH=/usr/local/bin:/usr/local/Cellar:$PATH
export ARCHFLAGS="-arch x86_64"
export LC_ALL="en_US.UTF-8"
export LANG="en_US.UTF-8"
alias python=/usr/local/bin/python
重启终端使其生效
$ type python
python is aliased to `python3'
$ python
Python 3.7.5 (default, Nov 1 2019, 02:16:32)
[Clang 11.0.0 (clang-1100.0.33.8)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
我在 OS Mojave 上,刚刚使用自制软件安装 geos
和 proj
,python3 消失了。我有两个版本,现在我只有 2.7 版本。我做了 brew install python3
,它说它已经安装但没有链接,然后我按照它的建议做了 brew link python
,但它返回了一个 Error: Could not symlink Frameworks/Python.framework/Headers Target /usr/local/Frameworks/Python.framework/Headers is a symlink belonging to python@2.
。
我怎样才能回到拥有两个版本的状态?。我不是 100% 安装 geos
,proj
是造成它的原因,但我 3 天前使用了 python3。自上次使用 python3.
phantomjs
我需要安装 python 的两个版本。由于我的计算机上似乎还有所有文件,因此处理此问题的适当方法是什么?
提前致谢!
安装虚拟环境,以便您可以使用许多不同版本的 Python。
使用 anaconda python 更适合 python 的发行版。
使用$ type python
查看它指向的位置。使用 brew info
命令列出已安装 python 的信息。
$ brew info python
python: stable 3.7.6 (bottled), HEAD
Interpreted, interactive, object-oriented programming language
https://www.python.org/
/usr/local/Cellar/python/3.7.5 (4,032 files, 61.8MB) *
Poured from bottle on 2019-11-04 at 22:34:01
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/python.rb
==> Dependencies
Build: pkg-config ✔
Required: gdbm ✔, openssl@1.1 ✔, readline ✔, sqlite ✔, xz ✔
==> Options
--HEAD
Install HEAD version
==> Caveats
Python has been installed as
/usr/local/bin/python3
Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, have been installed into
/usr/local/opt/python/libexec/bin
If you need Homebrew's Python 2.7 run
brew install python@2
You can install Python packages with
pip3 install <package>
They will install into the site-package directory
/usr/local/lib/python3.7/site-packages
See: https://docs.brew.sh/Homebrew-and-Python
查看 Caveats
Python has been installed as
/usr/local/bin/python3
那是您的 python3 别名路径。您可以安全地符号链接 python
以在 ~/.bash_profile
$ echo 'alias python=/usr/local/bin/python' > ~/.bash_profile
$ cat ~/.bash_profile
###########################
# you'll probably see these kind of lines before your alias
###########################
export PATH=/usr/local/bin:/usr/local/Cellar:$PATH
export ARCHFLAGS="-arch x86_64"
export LC_ALL="en_US.UTF-8"
export LANG="en_US.UTF-8"
alias python=/usr/local/bin/python
重启终端使其生效
$ type python
python is aliased to `python3'
$ python
Python 3.7.5 (default, Nov 1 2019, 02:16:32)
[Clang 11.0.0 (clang-1100.0.33.8)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>