一般ubuntu下有三种python环境,1. 系统自带python2,3;在/usr/bin路径下;2. anaconda下安装的python;3. anaconda下创建的env环境
[email protected]:~/caffe-ssd$ whereis python python: /usr/bin/python3.6m /usr/bin/python2.7-config /usr/bin/python2.7 /usr/bin/python3.6 /usr/bin/python3.6m-config /usr/bin/python /usr/bin/python3.6-config /usr/lib/python3.7 /usr/lib/python2.7 /usr/lib/python3.6 /etc/python2.7 /etc/python3.6 /etc/python /usr/local/lib/python2.7 /usr/local/lib/python3.6 /usr/include/python3.6m /usr/include/python2.7 /usr/include/python3.6 /usr/share/python /home/dsp/anaconda3/bin/python3.6m /home/dsp/anaconda3/bin/python3.6 /home/dsp/anaconda3/bin/python3.6m-config /home/dsp/anaconda3/bin/python /home/dsp/anaconda3/bin/python3.6-config /usr/share/man/man1/python.1.gz [email protected]-System-Product-Name:~/caffe-ssd$ python Python 3.6.5 |Anaconda, Inc.| (default, Apr 29 2018, 16:14:56) [GCC 7.2.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> exit() [email protected]-System-Product-Name:~/caffe-ssd$ activate py3.5 bash: /home/dsp/anaconda3/bin/activate: 权限不够 [email protected]-System-Product-Name:~/caffe-ssd$ source activate py3.5 (py3.5) [email protected]:~/caffe-ssd$ python Python 3.5.6 |Anaconda, Inc.| (default, Aug 26 2018, 21:41:56) [GCC 7.3.0] on linux Type "help", "copyright", "credits" or "license" for more information.
-当我们将:/home/dsp/anaconda3/bin添加到环境变量中时,用python命令得到时anaconda下的python环境;
然后如果时env环境,直接进入创建的虚拟环境即可;
[email protected]:~/caffe-ssd$ echo $PATH
/home/dsp/pycharm-community-2017.3.3/bin:/home/dsp/anaconda3/bin:/usr/local/cuda-9.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
- 如果时系统自带的环境,python2,3切换: linux下切换python2和python3
- 或者,待验证
python2切换到python3: echo alias python=python3 >> ~/.bashrc source ~/.bashrc python3切换到python2:gedit ~/.bashrc # alias python=python3 source ~/.bashrc
原文地址:https://www.cnblogs.com/ranjiewen/p/9745593.html
时间: 2024-10-03 00:41:20