I would like to change my PATH
from Python 2.6.1
to 3.1.2
. I have both versions installed on my computer, but when I type python --version
in the terminal I get Python 2.6.1
. So, thats the current version it's "pointing" to. Now if I type python3.1
it loads the version I want to use, although the PATH
is still
pointing to 2.6.1
. Downloaded along with the Python 3.1 package comes an Update Shell Profile.command
- when I run it and then run nano ~/.bash_profile
it says:
Setting PATH for Python 3.1 the orginal version is saved in .bash_profile.pysave PATH="/Library/Frameworks/Python.framework/Versions/3.1/bin:${PATH}" export PATH.
Does this mean that I have changed the PATH
, or does it just giving me instructions how to?
denis
20.7k9 gold badges63 silver badges84 bronze badges
asked Sep 12, 2010 at 18:56
1
PATH="/Library/Frameworks/Python.framework/Versions/3.1/bin:${PATH}"
export PATH
This will append the Python directory to the path.
If this is part of ~/.bash_profile
, this will append the Python path on each startup.
waiwai933
13.7k21 gold badges62 silver badges84 bronze badges
answered Sep 12, 2010 at 18:59
leolukleoluk
12k6 gold badges42 silver badges50 bronze badges
2
try the below lines
cd /usr/local/bin
cp python3.7 python
Then restart terminal
answered Mar 26, 2020 at 15:30
Vineesh TPVineesh TP
7,45911 gold badges60 silver badges122 bronze badges
i managed to fixed mine by removing python2, i don't if it's a good practice
answered Apr 10, 2020 at 14:10
code salleycode salley
1642 silver badges4 bronze badges
0
Educative Answers Team
PATH variable
The PATH variable is a list of directories where each directory contains a UNIX executable file [or its alias] for a command/program.
When a command is entered in the terminal, it searches for an executable file with the same name as the entered command in the PATH variable. In the event that the required file is not found, the terminal will respond with an error message saying that the command was not found.
One way to overcome this error is to write the complete directory of the executable file [or its alias] instead of just entering the command name. This, however, is not a very user-friendly approach.
An easier way to avoid this error is to add the executable files’ directory to the PATH variable. This often needs to be done after installing Python.
The complete path of the Python [or Python3] UNIX executable can be added [for OS X 10.8 Mountain Lion and up] by:
Opening the Terminal and entering the command:
sudo nano /etc/paths
. Enter your password when prompted to do so.A list of directories that are currently a part of the PATH variable will appear. Enter the path of the Python install directory at the end of this list.
Press
control + X
to quit and thenY
to save the changes.
Python can now be used directly from the Terminal without having to write its location every time. Try executing the command python --version
to output the default
version of Python installed on your system.
Use
python3 --version
to find out the version of Python3.x.
Copyright ©2022 Educative, Inc. All rights reserved