ale*_*nco 10 python install flask
我正在尝试安装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
Run Code Online (Sandbox Code Playgroud)
有什么建议可以解决这个问题?
我正在使用ubuntu 11.10.
Bur*_*lid 16
警告你可以放心地忽略; 但是这个错误:
error: could not create '/usr/local/lib/python2.7/dist-packages/flask': Permission denied
告诉我你正在尝试将它安装到你的全局系统Python中.没有错,但如果你想这样做,你需要使用提升的权限(使用sudo)运行命令.
最好使用虚拟环境,这样就不会污染系统范围的Python安装.
使用虚拟环境:
$ virtualenv flask_env
$ source flask_env/bin/activate
(flask_env) $ pip install Flask
Run Code Online (Sandbox Code Playgroud)
你应该首先安装virtualenv二进制文件 sudo apt-get install python-virtualenv
至于警告,有时可以忽略它们.唯一相关的行是最后一行,它表示应用程序无权在该文件夹中创建目录.
添加sudo到您的命令来解决此问题.
sudo pip install Flask
Run Code Online (Sandbox Code Playgroud)
作为一般规则,您不希望在系统范围内安装软件包.在Python世界中,规范是使用虚拟环境来创建本地环境,并将包安装到每个环境中.您可以在virtualenv 此处找到更多信息.