安装Pillow(Django)时出错

时间:2017-02-20 18:26:10

标签: python django command-line terminal pillow

我在安装Pillow时遇到了麻烦。 这是完整的追溯:

Collecting Pillow
  Using cached Pillow-4.0.0-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
Collecting olefile (from Pillow)
  Using cached olefile-0.44.zip
Installing collected packages: olefile, Pillow
  Running setup.py install for olefile ... error
    Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/bt/_3d4816x12d95tzvcp_0302w0000gn/T/pip-build-UyBMYN/olefile/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/bt/_3d4816x12d95tzvcp_0302w0000gn/T/pip-QHsEXV-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build/lib
    copying OleFileIO_PL.py -> build/lib
    creating build/lib/olefile
    copying olefile/__init__.py -> build/lib/olefile
    copying olefile/olefile.py -> build/lib/olefile
    copying olefile/README.rst -> build/lib/olefile
    copying olefile/README.html -> build/lib/olefile
    copying olefile/LICENSE.txt -> build/lib/olefile
    copying olefile/CONTRIBUTORS.txt -> build/lib/olefile
    running install_lib
    creating /Library/Python/2.7/site-packages/olefile
    error: could not create '/Library/Python/2.7/site-packages/olefile': Permission denied

    ----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/bt/_3d4816x12d95tzvcp_0302w0000gn/T/pip-build-UyBMYN/olefile/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/bt/_3d4816x12d95tzvcp_0302w0000gn/T/pip-QHsEXV-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/bt/_3d4816x12d95tzvcp_0302w0000gn/T/pip-build-UyBMYN/olefile/

错误似乎是“权限被拒绝”#39;在尝试创建文件夹时;虽然我不明白为什么......

我的机器正在运行Mac OSX,我正在使用终端来运行这个Django项目的命令。

2 个答案:

答案 0 :(得分:1)

因为普通用户无权全局安装软件包。使用sudo运行,或者 - 更好 - 使用virtualenv并在那里安装包。

答案 1 :(得分:0)

关于这个问题有几个问题,我建议你看看这些:

我更喜欢第二个,但它也取决于你的项目/应用程序结构