樹心幽徑

« 20190826 solve ubuntu boot directory full problem. | Main | 20190928商經一班遊計畫 »

20190826在ubuntu 裝python3.7.0.tgz、編寫並執行第1個程式
2019/08/26,13:47

REF1 :https://www.itread01.com/content/1545070623.html

(1)$ sudo apt-get install build-essential checkinstall

(2)$ sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev

(3)

$ cd /usr/src

$ sudo wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz

$ sudo tar xzf Python-3.7.0.tgz

(4)

$ cd Python-3.7.0

$ sudo ./configure --enable-optimizations

$ sudo make altinstall

:

    from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'
Makefile:1132: recipe for target 'altinstall' failed
make: *** [altinstall] Error 1
treehrt /usr/src/Python-3.7.0$

(5) 加裝libffi-dev

sudo apt install libffi-dev

(6) 重裝成功:

$sudo make altinstall

:fi
The directory '/home/treehrt/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/treehrt/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Looking in links: /tmp/tmp8w6516g5
Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
Successfully installed pip-10.0.1 setuptools-39.0.1

(7)察看版本

$ python3.7 -V
Python 3.7.0

(8)察看既有的版本

$ python -V
Python 2.7.12

(9)用vi編寫第1個python程式first.py

$ vi first.py

print("hello world!")

(10)執行first.py

$ python first.py
hello world!

$ python3.7 first.py
hello world!

迴響

 
Accessible and Valid XHTML 1.0 Strict and CSS Powered by LifeType