当前位置: 首页 > 面试题库 >

如何使Mac OS使用Homebrew安装的python

卢作人
2023-03-14
问题内容

我已经在网上搜索了一段时间以解决这个问题,到目前为止,我所做的是

  1. 在自制软件中安装了python32

  2. 更改了我的.bash_profile并向其中添加了以下行:

导出PATH = / usr / local / bin:/ usr / local / sbin:〜/ bin:$ PATH

但是,当我关闭终端并重新启动时,我键入“哪个python”,它仍然会打印:

/ usr / bin / python

并输入“ python –version”仍然:

Python 2.7.2

我还尝试了以下说明:

brew链接-覆盖python

或尝试通过运行以下指令来删除由homebrew安装的python:

酿造删除python

但以上两条指令均导致此错误:

错误:没有这样的桶:/ usr / local / Cellar / python

谁能帮忙,谢谢


问题答案:

如果要使用Homebrew安装Python 3:

$ brew install python3
==> Downloading http://python.org/ftp/python/3.3.0/Python-3.3.0.tar.bz2
Already downloaded: /Library/Caches/Homebrew/python3-3.3.0.tar.bz2
==> ./configure --prefix=/usr/local/Cellar/python3/3.3.0 --enable-ipv6 --datarootdir=/usr/local/Cell
==> make
==> make install PYTHONAPPSDIR=/usr/local/Cellar/python3/3.3.0
==> make frameworkinstallextras PYTHONAPPSDIR=/usr/local/Cellar/python3/3.3.0/share/python3
==> Downloading https://pypi.python.org/packages/source/d/distribute/distribute-0.6.35.tar.gz
Already downloaded: /Library/Caches/Homebrew/distribute-0.6.35.tar.gz
==> /usr/local/Cellar/python3/3.3.0/bin/python3.3 -s setup.py install --force --verbose --install-li
==> Downloading https://pypi.python.org/packages/source/p/pip/pip-1.3.1.tar.gz
Already downloaded: /Library/Caches/Homebrew/pip-1.3.1.tar.gz
==> /usr/local/Cellar/python3/3.3.0/bin/python3.3 -s setup.py install --force --verbose --install-li
==> Caveats
Homebrew's Python3 framework
  /usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework

Distribute and Pip have been installed. To update them
  pip3 install --upgrade distribute
  pip3 install --upgrade pip

To symlink "Idle 3" and the "Python Launcher 3" to ~/Applications
  `brew linkapps`

You can install Python packages with
  `pip3 install <your_favorite_package>`

They will install into the site-package directory
 /usr/local/lib/python3.3/site-packages
Executable python scripts will be put in:
 /usr/local/share/python3
so you may want to put "/usr/local/share/python3" in your PATH, too.

See: https://github.com/mxcl/homebrew/wiki/Homebrew-and-Python

安装完成后,更新系统PATH变量,将下一行添加到~/.bash_profile

export PATH=/usr/local/bin:/usr/local/sbin:~/bin:$PATH

接着:

$ source ~/.bash_profile

现在启动Python:

$ python3
Python 3.3.0 (default, Mar 26 2013, 10:01:40) 
[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.27)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>

您可以检查python3路径:

$ which python3
/usr/local/bin/python3


 类似资料:
  • 如果我写,酿造医生 帮帮我....我想用自制软件下载节点,我想解决所有警告...........

  • 我希望使用在Mac上安装Java。使用命令可以很好地工作。这将安装最新的稳定版本,当前为-。但是,如何安装特定的版本,例如。

  • 问题内容: 我需要能够在Python 2和3之间来回切换。如何使用Homebrew做到这一点,因为我不想弄乱路径并遇到麻烦。现在,我通过Homebrew安装了2.7。 问题答案: 我会用pyenv您可以安装它: 要在您的Bash shell中启用pyenv,您需要运行: 要在启动时自动为Bash执行此操作,请将该行添加到您的中。1个 用法: 安装并激活pyenv后,您可以安装不同版本的python

  • 我想用自制软件在我的Mac上安装OpenJDK 8版1.8.0.119。安装时指定版本的brew命令是什么? 我可以使用brew命令

  • 问题内容: 。已记录的重新安装Python和openssl的解决方法不起作用,因此我决定卸载并重新安装Python。 问题是,当您尝试通过brew安装Python 2时,会收到以下消息: 不幸的是,我仍然有许多取决于Brew的python @ 2的brew公式。这些包括,,PR例如 我不知道如何使用他们记录的命令重新安装Python @ 2。它需要一个公式和一个水龙头。我想公式会是。我不确定水龙头

  • 如果我在自制的MacOS Mojave上这样做: 我得到: 我已经找了好几天了,也尝试了各种解决方案,比如这里,但是至今没有运气。知道我为什么会出现这个错误以及如何修复它吗? 提前感谢!

  • 我有postgresql数据库,通过自制安装在我的macOS系统驱动器上。系统驱动器不是很大,数据库变得越来越大。如果可能的话,我想把它移到我的大数据驱动器上。我找到了一本Ubuntu的手册,但它似乎不适合我的情况。因为它表示postgresql.conf位于数据库本身之外的其他目录中。但Homebrew的数据库位于/usr/local/var/postgres,其中包含postgreql.con