Python 尝试安装Flask 0.9后出现警告和错误

Python 尝试安装Flask 0.9后出现警告和错误,python,installation,flask,Python,Installation,Flask,我正在尝试ot安装,但我打赌所有这些警告和错误: alex@alex-K43U:~/flask$ pip install Flask Downloading/unpacking Flask Downloading Flask-0.9.tar.gz (481Kb): 481Kb downloaded Running setup.py egg_info for package Flask warning: no files found matching '*' under dire

我正在尝试ot安装,但我打赌所有这些警告和错误:

alex@alex-K43U:~/flask$ pip install Flask
Downloading/unpacking Flask
  Downloading Flask-0.9.tar.gz (481Kb): 481Kb downloaded
  Running setup.py egg_info for package Flask

    warning: no files found matching '*' under directory 'tests'
    warning: no previously-included files matching '*.pyc' found under directory 'docs'
    warning: no previously-included files matching '*.pyo' found under directory 'docs'
    warning: no previously-included files matching '*.pyc' found under directory 'tests'
    warning: no previously-included files matching '*.pyo' found under directory 'tests'
    warning: no previously-included files matching '*.pyc' found under directory 'examples'
    warning: no previously-included files matching '*.pyo' found under directory 'examples'
    no previously-included directories found matching 'docs/_build'
    no previously-included directories found matching 'docs/_themes/.git'
Downloading/unpacking Werkzeug>=0.7 (from Flask)
  Downloading Werkzeug-0.8.3.tar.gz (1.1Mb): 1.1Mb downloaded
  Running setup.py egg_info for package Werkzeug

    warning: no files found matching '*' under directory 'werkzeug/debug/templates'
    warning: no files found matching '*' under directory 'tests'
    warning: no previously-included files matching '*.pyc' found under directory 'docs'
    warning: no previously-included files matching '*.pyo' found under directory 'docs'
    warning: no previously-included files matching '*.pyc' found under directory 'tests'
    warning: no previously-included files matching '*.pyo' found under directory 'tests'
    warning: no previously-included files matching '*.pyc' found under directory 'examples'
    warning: no previously-included files matching '*.pyo' found under directory 'examples'
    no previously-included directories found matching 'docs/_build'
Downloading/unpacking Jinja2>=2.4 (from Flask)
  Downloading Jinja2-2.6.tar.gz (389Kb): 389Kb downloaded
  Running setup.py egg_info for package Jinja2

    warning: no previously-included files matching '*' found under directory 'docs/_build'
    warning: no previously-included files matching '*.pyc' found under directory 'jinja2'
    warning: no previously-included files matching '*.pyc' found under directory 'docs'
    warning: no previously-included files matching '*.pyo' found under directory 'jinja2'
    warning: no previously-included files matching '*.pyo' found under directory 'docs'
Installing collected packages: Flask, Werkzeug, Jinja2
  Running setup.py install for Flask

    warning: no files found matching '*' under directory 'tests'
    warning: no previously-included files matching '*.pyc' found under directory 'docs'
    warning: no previously-included files matching '*.pyo' found under directory 'docs'
    warning: no previously-included files matching '*.pyc' found under directory 'tests'
    warning: no previously-included files matching '*.pyo' found under directory 'tests'
    warning: no previously-included files matching '*.pyc' found under directory 'examples'
    warning: no previously-included files matching '*.pyo' found under directory 'examples'
    no previously-included directories found matching 'docs/_build'
    no previously-included directories found matching 'docs/_themes/.git'
    error: could not create '/usr/local/lib/python2.7/dist-packages/flask': Permission denied
    Complete output from command /usr/bin/python -c "import setuptools;__file__='/home/alex/flask/build/Flask/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-KD7NsY-record/install-record.txt:
    running install

running build

(a lot of creating and building)

error: could not create '/usr/local/lib/python2.7/dist-packages/flask': Permission denied
有什么解决这个问题的建议吗


我正在使用Ubuntu11.10。

您可以安全忽略的警告;但是,此错误:

错误:无法创建“/usr/local/lib/python2.7/dist包/flask”:权限被拒绝

告诉我您正在尝试将其安装到全局系统Python中。这没什么错,但是如果您想这样做,您需要以提升的权限运行该命令(使用
sudo

最好使用一个,这样就不会污染系统范围的Python安装

使用虚拟环境:

$ virtualenv flask_env
$ source flask_env/bin/activate
(flask_env) $ pip install Flask

您可能应该首先使用
sudo apt get install python virtualenv
安装virtualenv二进制文件。至于警告,有时可以忽略它们。唯一相关的一行是最后一行,它表示应用程序没有在该文件夹中创建目录的权限

sudo
添加到命令中以修复此问题

sudo pip install Flask

一般来说,您不希望在系统范围内安装软件包。在Python世界中,规范是使用virtualenv创建本地环境,并将包安装到每个环境中。您可以在
virtualenv
上找到更多信息,非常感谢。为什么官方文件中没有?顺便问一下,如何退出virtualev(flask_env)alex@alex-K43U:~$
?这对我很有用。不要在ubuntu中使用sudo int virtualenv。
(flask\u env)$sudo pip install flask
。我发现sudo在MacOSX中还可以,但在ubuntu中却不行