0

我有一个程序,可以从终端(无虚拟环境)运行,我使用--user选项安装软件包。现在我想在Python 2.7中使用requirements.txt,setup.py等以适当的方式组织程序。 为此,我创建了一个虚拟环境,并安装了所有必需的软件包,以便我可以执行“点击冻结> requirements.txt“。在没有sudo的虚拟环境中安装Pillow/PIL的问题

不幸的是我不能安装PIL/Pillow。我曾经遇到过jpeg的问题,但我用“sudo apt-get install libjpeg-dev”修复了这个问题。现在这些:

pip install Pillow 
pip install Pillow --allow-external Pillow --allow-unverified Pillow 

我得到许可被拒绝:

... 
error: could not create '/home/kinkyboy/virtualenv/tantrix/lib/python2.7/site-packages/PIL': Permission denied 

---------------------------------------- 
Cleaning up... 
Command /home/kinkyboy/virtualenv/tantrix/bin/python -c "import setuptools, tokenize;__file__='/home/kinkyboy/virtualenv/tantrix/build/Pillow/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-S9cPV3-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/kinkyboy/virtualenv/tantrix/include/site/python2.7 failed with error code 1 in /home/kinkyboy/virtualenv/tantrix/build/Pillow 
Storing debug log for failure in /home/kinkyboy/.pip/pip.log 

如果我使用sudo它的工作原理,并与--user没有,但很明显,这些命令不会在虚拟安装环境。 我错过了什么吗?

+0

哪个用户构建的虚拟环境?在我看来,虚拟环境可能已经由root用户构建。 –

+0

如果您*以前不适当地使用'sudo',则可能会弄乱权限,因此您无法轻易修复它。 'sudo apt-get'只是关于* only *的安全使用。 – o11c

+0

我正在阅读有关chown'ing〜/ .cache/pip文件的内容,但它已由我的用户(kinkyboy)拥有,但虚拟环境由root拥有。让我尝试虚拟环境 – aless80

回答

0

解决方案是为虚拟环境寻找路径。确保〜/ .cache/pip和虚拟环境的路径都由用户拥有。在我的情况下,第二次是没有

须藤乔敦 - R的your_username:your_username路径/到/ virtuaelenv/

见@Vingtoft这里: StackOverflow 19471972

+0

'sudo chown -R kinkyboy/home/kinkyboy' – phd

相关问题