- Flask By Example
- Gareth Dwyer
- 309字
- 2021-07-09 20:06:52
Creating our development environment
A development environment consists of all the software that a developer uses while building software. For starters, we'll install a Python package manager (pip) and the Flask package. In this book, we'll show detailed steps for developing using Python 2.7 on a clean installation of Ubuntu 14.04, but everything should be easy to translate to Windows or OS X.
Installing pip
For our Hello World application, we only need the Python Flask package, but we'll install several Python packages throughout the development process of our three applications. To manage these packages, we'll use the Python package manager pip. If you've developed in Python without a package manager until now, you'll love how easy it is to download, install, remove, and update packages using pip. If you already use it, then skip to the next step where we'll use it to install Flask.
The pip manager is included in Python's 3.4+ and 2.7.9+ versions. For older versions of Python, pip needs to be installed. To install pip on Ubuntu, open a terminal and run the following command:
sudo apt-get update sudo apt-get install python-pip
Note
To install pip on Windows or OS X, you can download and run the get-pip.py
file from the pip homepage at https://pip.pypa.io/en/latest/installing/#install-or-upgrade-pip.
That's it! You can now easily install any Python package you need through pip.
Installing Flask
Installing Flask through pip could not be more straightforward. Simply run the following:
pip install –-user flask
You might see some warnings in your terminal, but at the end, you should also see Successfully installed Flask. Now, you can import Flask into a Python program just as with any other library.
Note
If you're used to using VirtualEnv for Python development, you can install Flask inside a VirtualEnv environment. We will discuss this further in Appendix, A Sneak Peek into the Future.
- 觸·心:DT時(shí)代的大數(shù)據(jù)精準(zhǔn)營(yíng)銷
- 零基礎(chǔ)搭建量化投資系統(tǒng):以Python為工具
- 在最好的年紀(jì)學(xué)Python:小學(xué)生趣味編程
- Ext JS Data-driven Application Design
- 零基礎(chǔ)學(xué)MQL:基于EA的自動(dòng)化交易編程
- Hands-On Microservices with Kotlin
- 零基礎(chǔ)學(xué)Python網(wǎng)絡(luò)爬蟲(chóng)案例實(shí)戰(zhàn)全流程詳解(高級(jí)進(jìn)階篇)
- Highcharts Cookbook
- Arduino家居安全系統(tǒng)構(gòu)建實(shí)戰(zhàn)
- Java語(yǔ)言程序設(shè)計(jì)教程
- 30天學(xué)通C#項(xiàng)目案例開(kāi)發(fā)
- The Statistics and Calculus with Python Workshop
- C語(yǔ)言程序設(shè)計(jì)與應(yīng)用實(shí)驗(yàn)指導(dǎo)書(shū)(第2版)
- Android嵌入式系統(tǒng)程序開(kāi)發(fā)(基于Cortex-A8)
- Developing Java Applications with Spring and Spring Boot