日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

ipython使用 python3,2019-04-29 python/ipython设置默认python3

發布時間:2023/12/19 python 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。