简体   繁体   中英

Use system python in homebrew

Is it possible to use system python in homebrew?

I have python 2.7.5 installed on my mac, but when I try to install any homebrew package with python in dependencies, it starts loading python 2.7.9.

It is important for me to use system python because of lots of installed python packages.

What version of python homebrew uses depends on two things:

  • Where the python alias points to.
  • What the python path is in the formula.

In most cases, homebrew forumlae simply use the python command, and does not specify a python path. If it does, then it is usually /usr/bin/python .

So, you can fix the problem in two ways:

  • Change the homebrew formulate to point to the right python interpreter of your choice.
  • Change where the python command points to.

The first option is problematic, since it means that you need to go into your Cellar folder, and alter things. This is not nice, and usually not required.

A better alternative is to point to the right python command. This is where pyenv comes in handy. pyenv is a command line tool that helps you manage different versions of python. Follow the instructions here:

https://github.com/yyuu/pyenv-installer

to install it.

Once that is done, change your python command to whatever version of python you'd like it to point to.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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