Flask安装 - 错误

时间:2016-10-11 15:34:09

标签: python pip virtualenv

我尝试在拥有Linux Mint的PC上的虚拟环境中安装Flask。结束了这个错误:

*error: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/itsdangerous.py'
---------------------------------------------------------------------- Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-cMPDih/itsdangerous/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-HIVrsp-record/install-record.txt
--single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-cMPDih/itsdangerous/*

1 个答案:

答案 0 :(得分:2)

错误消息表明您未在虚拟环境中工作。你可能还没有激活它。您可以轻松地测试和激活它:

$ which python
/usr/bin/python # oops, no virtual environment
$ source /home/user/venv/bin/activate
$ which python
/home/user/venv/bin/python # correct
$ pip install flask

您需要每次都进行激活。您可以创建一个启动脚本,例如在bash中运行程序时激活它:

#!/bin/bash
source /home/user/venv/bin/activate
python /home/user/venv/myproject/main.py
相关问题