湖濱散記部落格的樹心幽徑[login][主頁]
499:20190826在ubuntu 裝python3.7.0.tgz、編寫並執行第1個程式

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!


select id,article_id,topic,text from lt_articles_text where article_id =499; ok. update lt_articles set num_reads=num_reads +1 where id=499; ok.