Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup python path for 2.7 on mac?

I am aware that, this question has been asked and answered many times. But, still i couldn't get rid of this. I found out the following info on my mac.

cd /Library/Frameworks/Python.framework/Versions/
Current -> 2.7
3.6

whereispython
/usr/bin/python

which python
/usr/bin/python

which -a python
/usr/bin/python
/usr/bin/python

python
Python 2.7.10 (default) 
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

Even though, when i edit ~/.bash_profile as below

# Setting PATH for Python 2.7
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH

#PYTHONPATH
PYTHONPATH="${PYTHONPATH}:/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python"
export PYTHONPATH

Then, source ~/.bash-profile. After restarting my mac & terminal, could see still /usr/bin/python instead of pointing to /Library/../Python2.7 when executed which python.

I uninstalled python and re-installed "pip install python" And also, i could see python installed under /System/Library/Frameworks/Python.framework/Versions

2.6
2.7
2.5 -> 2.6
2.3 -> 2.6
Current -> 2.7

I am not sure what could be missing here. How can i set/add the python path in mac ? Please help me to understand and overcome this. Can you please help me here ?

Reference Adding python path to mac osx

like image 679
Diesel Kumar Avatar asked Dec 23 '22 15:12

Diesel Kumar


1 Answers

Install via brew. brew install python2 or python3. brew sets the python path in mac automatically.

like image 106
bsd007 Avatar answered Jan 09 '23 19:01

bsd007