As I understood, I have two versions of python 2.7 installed on my machine. One is located in /usr/bin
and another one is in /usr/local/bin
. When I type python in the shell, it calls one in /usr/local/bin
, and it doesn't have access to all the packages installed using apt-get
and pip. I have tried to set up an alias, but when I type sudo python
it still calls one in /usr/local/bin
. I want to always use one in /usr/bin
, since I have all the packages there. How do I do that?
you can easily have two python version in your machine. But first I recommend to install the Anaconda package.
And then you can create an environment with python 3 version
conda create --name test_env python=3 numpy pandas
In order to activate it, you need to write in your terminal
source activate test_env
More info here: https://conda.io/docs/using/envs.html
From what I understood,
Update your ~/.bashrc and append this line at the end
alias python=/usr/bin/python
Then open a new terminal. Or do source ~/.bashrc
in the current terminal
Run which python
to see the location of the python executable. It will show you /usr/bin/python
Also, if you want to get packages in your current python (ie /usr/local/bin/python) you can use pip with that particular python version.
which pip
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.