《Python入门》Linux 下 Python Web开发环境搭建笔记
来源:互联网 发布:投资失败一无所有 知乎 编辑:程序博客网 时间:2024/04/30 18:57
之前写过 Windows 7下Python Web开发环境搭建笔记,今天写一下在Linux系统下搭建Python Web的开发测试环境。
我使用的系统是:ubuntu 14.04 server,根据个人经验,CentOS 6.5 下也适用。
关于Python的版本
进入Python的网站,鼠标移到导航条上的下载,我们会发现提供两下主版本的下载链接!
这两个之间存在什么差别呢?
个人理解,2.7.x的版本为更加稳定的版本,而3.x的版本则是比较前卫的版本,包含了很多新功能新特性之类的;
但如果想要用Python开发一个新项目,那么该如何选择Python版本呢?大部分Python库都同时支持Python 2.7.x和3.x版本的,所以不论选择哪个版本都是可以的。
但有一些需要注意的区别,参考:Python 2.7.x 和 3.x 版本的重要区别小结
下载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这里只需要执行 make 就可以了, 不需要执行 makeinstall。
注意,系统中可能还没有安装 make,会出现如下提示:
# makeThe program 'make' is currently not installed. You can install it by typing:apt-get install make然后我们可以根据提示,执行以下命令安装:
# apt-get install make输出如下:
# apt-get install makeReading package lists... DoneBuilding dependency tree Reading state information... DoneSuggested packages: make-docThe following NEW packages will be installed: make0 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) ...安装成功之后再执行 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_scriptscreating build/scripts-2.7copying and adjusting /home/aven/Python-2.7.11/Tools/scripts/pydoc -> build/scripts-2.7copying and adjusting /home/aven/Python-2.7.11/Tools/scripts/idle -> build/scripts-2.7copying and adjusting /home/aven/Python-2.7.11/Tools/scripts/2to3 -> build/scripts-2.7copying and adjusting /home/aven/Python-2.7.11/Lib/smtpd.py -> build/scripts-2.7changing mode of build/scripts-2.7/pydoc from 644 to 755changing mode of build/scripts-2.7/idle from 644 to 755changing mode of build/scripts-2.7/2to3 from 644 to 755changing 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= 集成开发环境= 把开发相关的各种环境(和工具)都集成到一起
Python IDE= Python的集成开发环境= 把和Python开发相关的各种工具
有几种可以选择:
- PyDev
- Komodo Edit
- PyCharm
- Atom with Python plugin
Hello World
保存文件,执行查看结果:
小结
到这里Python Web的开发环境就搭建完了,非常的简单!
有的小伙伴可能怒了,我还没看到Web的影子呢!
哈哈,我也是刚刚发现,Python和Go语言一样,Web服务器可以自己写;
下一篇:《Python入门》第一个Python Web程序——简单的Web服务器
- 《Python入门》Linux 下 Python Web开发环境搭建笔记
- 《Python入门》Windows 7下Python Web开发环境搭建笔记
- Windows 7下Python Web开发环境搭建笔记
- ubuntu下python web开发环境搭建
- Python Web开发环境搭建
- python tornado web window7 开发笔记1:环境搭建
- ubuntu 下 搭建 python+apache+django+mysql web开发环境
- 搭建python的web开发环境 windows下
- Windows版本下的Python Web 开发环境搭建
- Linux下Python环境搭建
- Linux下Python环境搭建
- Linux下搭建Python环境
- linux 下 python 环境搭建
- linux下搭建Python环境
- linux下搭建python环境
- Linux搭建Python开发环境
- linux下用eclipse搭建python集成开发环境!
- linux下pycharm和anaconda搭建python开发环境
- Android源码桥梁模式---FragmentCompat
- 1002 写出这个数 (20)
- Android读书笔记(一)Activity退出时释放内存
- qsort和sort的一些小结
- 4月份英语学习
- 《Python入门》Linux 下 Python Web开发环境搭建笔记
- LeetCode *** 341. Flatten Nested List Iterator(审题审题!!)
- linux系统编程之进程(三):进程复制fork,孤儿进程,僵尸进程
- iOS开发点滴-添加阴影效果
- C++ primer 读书笔记 第九章 顺序容器
- python学习之旅之python环境的配置
- hdu Cyclic Nacklace kmp
- 修改UITextField placeholder 文字颜色
- 剑指offer(28):二叉搜索树与双向链表