【问题标题】:Warnings and errors after trying to install Flask 0.9尝试安装 Flask 0.9 后的警告和错误
【发布时间】:2012-10-22 15:46:20
【问题描述】:

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

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。

【问题讨论】:

    标签: python installation flask


    【解决方案1】:

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

    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 二进制文件

    【讨论】:

    • 哇,非常感谢。官方文档里怎么没有?顺便问一下,我该如何退出virtualev(flask_env)alex@alex-K43U:~$
    • 这对我有用。不要在 ubuntu.(flask_env) $ sudo pip install Flask 中使用 sudo int virtualenv。我发现 sudo 在 mac osx 中可以,但在 ubuntu 中不工作
    【解决方案2】:

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

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

    sudo pip install Flask
    

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-14
      • 1970-01-01
      • 2020-10-11
      相关资源
      最近更新 更多