linux--using a domestic image to install some Python packages via Pip

Source: Internet
Author: User
Tags virtual environment virtualenv

Learn flask, install virtualenv environment, these belts are OK, but an installation package always error can not be installed,

http://e.pypi.python.org/This is the official website, Tsinghua University provides

Recommended for non-Tsinghua campus Use this image: Http://e.pypi.python.org/simple (This is also a http://pypi.v2ex.com/simple), Tsinghua University in the use of this:/http Mirrors.tuna.tsinghua.edu.cn/pypi/simple


Using the mirroring method, you can add the parameter "-I http://e.pypi.python.org/simple" Each time Pip is executed,

Alternatively, you can configure it locally so that you don't have to add parameters each time, and apply the cheer Xiao Configuration (http://blog.makto.me/post/2012-11-01/pypi-mirror):

[Plain]
    1. Users who use the PIP can be configured as follows:
    2. In Unix and MacOS, the configuration file is: $HOME/.pip/pip.conf
    3. On Windows, the configuration file is:%home%\pip\pip.ini
    4. You need to add the following in the configuration file:
    5. [Global]
    6. Index-url=http://mirrors.tuna.tsinghua.edu.cn/pypi/simple

There is also a small trick, is to put all the packages to be installed in a file, such as Requirement.txt (each package to write a line, the top of the wardrobe), and then PIP installation only need to add the parameter "-R requirement.txt".


After installation, experienced a, the speed of the ~ ~


Ps:

Steps to use:

1. Enter the directory using the command:virtualenv env

2.source Env/bin/activate, this time you will find an extra (env) logo in front of the command line, indicating that you have entered the virtual environment.

Write a simple hello.py verification:

[Python]
  1. #!/usr/bin/python
  2. From Flask Import flask
  3. App = Flask (__name__)
  4. @app. Route ('/', methods = [' GET ', ' POST '])
  5. def hello ():
  6. return ' Hello world! '
  7. if __name__ = = ' __main__ ':
  8. App.run ()

Hint no flask package, use the method above Pip, Pip install-i http://e.pypi.python.org/simple flask, super fast, install, run, OK.

Why did you install the wine OK? And does not affect the original package of the system?

Look at the contents of the Env directory and findthese installed packages in the ENV/L ib/pythonx.x/site-packages directory, such as my following:

[Plain]
  1. Distribute-0.6.24-py2.7.egg Itsdangerous-0.23-py2.7.egg-info Jinja2-2.7.1-py2.7.egg-info setuptools.pth
  2. Easy-install.pth itsdangerous.py Markupsafe Werkzeug
  3. Flask ITSDANGEROUS.PYC Markupsafe-0.18-py2.7.egg-info werkzeug-0.9.3-py2.7.egg-in Fo
  4. Flask-0.10.1-py2.7.egg-info JINJA2 Pip-1.1-py2.7.egg


This is what a virtual machine does.

Finally, I can concentrate on the flask with peace of mind.


#2013.08.27

Direct installation flask Installs the latest 0.10 version, it is tragic that many expansion packs have not yet followed this version, so many features can not be used OH ~ ~ such as the Falsk-mail version

So still reinstall Flask version 0.9, but this is not a thing, with envitualenv after the environment is very easy, today tried the-I http://e.pypi.python.org/simple I can't believe it! , find this mirror address good http://pypi.v2ex.com/simple

Oh, it's also easy to install the Flask0.9 version, just pip install flask==0.9.



(decide after each article to put a funny picture, let yourself happy AH)

linux--using a domestic image to install some Python packages via Pip

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.