官术网_书友最值得收藏!

  • 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.

主站蜘蛛池模板: 新巴尔虎左旗| 山阳县| 宁津县| 遂昌县| 都兰县| 赣榆县| 辰溪县| 偃师市| 鹤壁市| 双流县| 弋阳县| 金坛市| 东至县| 历史| 吴旗县| 衡阳市| 广宁县| 杭州市| 且末县| 若尔盖县| 沙坪坝区| 中江县| 普陀区| 井陉县| 金阳县| 来宾市| 彰武县| 汶川县| 阳泉市| 贵阳市| 七台河市| 聂拉木县| 库伦旗| 府谷县| 高雄市| 江西省| 县级市| 永泰县| 金阳县| 银川市| 天气|