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

时间:2012-10-22 15:46:21

标签: python install flask

尝试安装Flask,但是#39; m下注所有这些警告和错误:

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

有任何解决此问题的建议吗?

我使用的是ubuntu 11.10。

2 个答案:

答案 0 :(得分:16)

警告你可以放心地忽略;但是这个错误:

error: could not create '/usr/local/lib/python2.7/dist-packages/flask': Permission denied

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

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

使用虚拟环境:

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

您应该首先使用sudo apt-get install python-virtualenv

安装virtualenv二进制文件

答案 1 :(得分:6)

至于警告,有时可以忽略它们。唯一相关的行是最后一行,它表示应用程序无权在该文件夹中创建目录。

sudo添加到您的命令中以解决此问题。

sudo pip install Flask

作为一般规则,您不希望在系统范围内安装软件包。在Python世界中,规范是使用虚拟环境来创建本地环境,并将包安装到每个环境中。您可以在virtualenv here找到更多信息。