欧美三级国产三级日韩三级_亚洲熟妇丰满大屁股熟妇_欧美亚洲成人一区二区三区_国产精品久久久久久模特

《Python入門》Linux 下 Python Web開發(fā)環(huán)境搭建筆記 - 新聞資訊 - 云南小程序開發(fā)|云南軟件開發(fā)|云南網站建設-昆明葵宇信息科技有限公司

159-8711-8523

云南網建設/小程序開發(fā)/軟件開發(fā)

知識

不管是網站,軟件還是小程序,都要直接或間接能為您產生價值,我們在追求其視覺表現的同時,更側重于功能的便捷,營銷的便利,運營的高效,讓網站成為營銷工具,讓軟件能切實提升企業(yè)內部管理水平和效率。優(yōu)秀的程序為后期升級提供便捷的支持!

您當前位置>首頁 » 新聞資訊 » 網站建設 >

《Python入門》Linux 下 Python Web開發(fā)環(huán)境搭建筆記

發(fā)表時間:2016-4-26

發(fā)布人:葵宇科技

瀏覽次數:80

之前寫過 Windows 7下Python Web開發(fā)環(huán)境搭建筆記,今天寫一下在Linux系統下搭建Python Web的開發(fā)測試環(huán)境。

我使用的系統是:ubuntu 14.04 server,CentOS 參考我的最新記錄:CentOS release 6.10 下 Python 3.7.5 安裝記錄。

關于Python的版本

進入Python的網站,鼠標移到導航條上的下載,我們會發(fā)現提供兩下主版本的下載鏈接!

這兩個之間存在什么差別呢?

個人理解,2.7.x的版本為更加穩(wěn)定的版本,而3.x的版本則是比較前衛(wèi)的版本,包含了很多新功能新特性之類的;

但如果想要用Python開發(fā)一個新項目,那么該如何選擇Python版本呢?大部分Python庫都同時支持Python 2.7.x和3.x版本的,所以不論選擇哪個版本都是可以的。

但有一些需要注意的區(qū)別,參考:Python 2.7.x 和 3.x 版本的重要區(qū)別小結

下載Python

由于Bluemix中如果未指定版本,缺省情況下會選擇 V2.7.10,所以我決定下載安裝 V2.7.10。

我的操作系統是ubuntu 14.04 server,Linux系統通常都是通過源碼進行安裝;

可以直接使用以下命令下載:

wget https://www.python.org/ftp/python/2.7.11/Python-2.7.11.tar.xz

點擊下圖進入Python下載頁面,找到下載地址;

選擇你想使用的版本:

XZ格式的壓縮率通常是最高的,所以我這里選擇XZ格式的包;

安裝Python

解壓剛剛下載的安裝包

# xz -d Python-2.7.11.tar.xz
# tar -xvf Python-2.7.11.tar

進入文件目錄:

# cd Python-2.7.11

配置

# ./configure

安裝

# make

這里只需要執(zhí)行 make 就可以了, 不需要執(zhí)行 makeinstall。

注意,系統中可能還沒有安裝 make,會出現如下提示:

# make
The program 'make' is currently not installed. You can install it by typing:
apt-get install make

然后我們可以根據提示,執(zhí)行以下命令安裝:

# apt-get install make

輸出如下:

# apt-get install make
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Suggested packages:
  make-doc
The following NEW packages will be installed:
  make
0 upgraded, 1 newly installed, 0 to remove and 48 not upgraded.
Need to get 119 kB of archives.
After this operation, 328 kB of additional disk space will be used.
Get:1 http://hk.archive.ubuntu.com/ubuntu/ trusty/main make amd64 3.81-8.2ubuntu3 [119 kB]
Fetched 119 kB in 7s (16.0 kB/s)
Selecting previously unselected package make.
(Reading database ... 80371 files and directories currently installed.)
Preparing to unpack .../make_3.81-8.2ubuntu3_amd64.deb ...
Unpacking make (3.81-8.2ubuntu3) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Setting up make (3.81-8.2ubuntu3) ...

安裝成功之后再執(zhí)行 make 命令,這個過程可能有點慢,需要等一會兒。

以下為最后部分輸出:

Python build finished, but the necessary bits to build these modules were not found:
_bsddb             _curses            _curses_panel   
_sqlite3           _ssl               _tkinter        
bsddb185           bz2                dbm             
dl                 gdbm               imageop         
readline           sunaudiodev        zlib            
To find the necessary bits, look in setup.py in detect_modules() for the module's name.

running build_scripts
creating build/scripts-2.7
copying and adjusting /home/aven/Python-2.7.11/Tools/scripts/pydoc -> build/scripts-2.7
copying and adjusting /home/aven/Python-2.7.11/Tools/scripts/idle -> build/scripts-2.7
copying and adjusting /home/aven/Python-2.7.11/Tools/scripts/2to3 -> build/scripts-2.7
copying and adjusting /home/aven/Python-2.7.11/Lib/smtpd.py -> build/scripts-2.7
changing mode of build/scripts-2.7/pydoc from 644 to 755
changing mode of build/scripts-2.7/idle from 644 to 755
changing mode of build/scripts-2.7/2to3 from 644 to 755
changing mode of build/scripts-2.7/smtpd.py from 644 to 755
/usr/bin/install -c -m 644 ./Tools/gdb/libpython.py python-gdb.py

到這里就安裝完成了,輸入“Python”,然后回車看看吧!

如何退出 Python 命令行? Ctrl + Z 就可以了。

關于Pip

pip是一個安裝和管理Python包的工具,是easy_install的一個替換品。

看到網上一些文章介紹Pip還需要單獨安裝,已經過時了,經過上面的步驟,Pip已經被安裝好了;

關于Python IDE

什么是IDE?
IDE= 集成開發(fā)環(huán)境= 把開發(fā)相關的各種環(huán)境(和工具)都集成到一起

Python IDE= Python的集成開發(fā)環(huán)境= 把和Python開發(fā)相關的各種工具

有幾種可以選擇:

  • PyDev
  • Komodo Edit
  • PyCharm
  • Atom with Python plugin

Hello World

Python要求嚴格的縮進:

[python] view plain copy
  1. #!/usr/bin/python
  2. # -*- coding: UTF-8 -*-
  3. print 'hello world'
  4. for i in range(1,5):
  5. for j in range(1,5):
  6. for k in range(1,5):
  7. if( i != k ) and (i != j) and (j != k):
  8. print 'hello world', i,j,k

保存文件,執(zhí)行查看結果:

小結

到這里Python Web的開發(fā)環(huán)境就搭建完了,非常的簡單!

有的小伙伴可能怒了,我還沒看到Web的影子呢!

哈哈,我也是剛剛發(fā)現,Python和Go語言一樣,Web服務器可以自己寫;

下一篇:《Python入門》第一個Python Web程序——簡單的Web服務器

相關案例查看更多