ipython使用 python3,2019-04-29 python/ipython设置默认python3
現在都用python 3了,mac本子默認2.7,不太方便,琢磨著默認改成3。先看下當前python環境,默認是2.7
axing@AX:~/axpython$ whereis python
python: /usr/bin/python2.7 /usr/bin/python2.7-config /usr/bin/python3.6m-config /usr/bin/python /usr/bin/python3.6 /usr/bin/python3.6m /usr/bin/python3.6-config /usr/lib/python2.7 /usr/lib/python3.6 /usr/lib/python3.7 /etc/python2.7 /etc/python /etc/python3.6 /etc/python3.7 /usr/local/lib/python2.7 /usr/local/lib/python3.6 /usr/include/python2.7 /usr/include/python3.6 /usr/include/python3.6m /usr/share/python /usr/share/man/man1/python.1.gz
設定python3為默認python版本
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 100
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6 150
進入python,再看一下,已經改好了。
axing@AX:~/axpython$ python
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
再看下ipython, 記得用 “pip install ipython” 安裝python2的, “pip3 install ipython” 安裝python3的。
ipython運行報錯
axing@AX:~/axpython$ ipython
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.4.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: %run read_yaml.py
ERROR:root:File `'%.py'` not found.
看下工作目錄,在當前工作目錄下找py文件:
axing@Bastion_LD8:~/axpython$ ipython
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.4.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: %pwd
Out[1]: '/home/axing/axpython'
In [2]: %run read_yaml.py
總結
以上是生活随笔為你收集整理的ipython使用 python3,2019-04-29 python/ipython设置默认python3的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 二进制安装mysql 5.7、maria
- 下一篇: Python 3.5.2 TypeErr