Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在Mac OS上安装带pip的PIL?_Python_Macos_Python 2.7_Installation_Python Imaging Library - Fatal编程技术网

Python 如何在Mac OS上安装带pip的PIL?

Python 如何在Mac OS上安装带pip的PIL?,python,macos,python-2.7,installation,python-imaging-library,Python,Macos,Python 2.7,Installation,Python Imaging Library,我正在尝试使用以下命令安装PIL(Python映像库): sudo pip install pil 但我得到了以下信息: Downloading/unpacking PIL You are installing a potentially insecure and unverifiable file. Future versions of pip will default to disallowing insecure files. Downloading PIL-1.1.7.tar.

我正在尝试使用以下命令安装PIL(Python映像库):

sudo pip install pil
但我得到了以下信息:

Downloading/unpacking PIL
  You are installing a potentially insecure and unverifiable file. Future versions of pip will default to disallowing insecure files.
  Downloading PIL-1.1.7.tar.gz (506kB): 506kB downloaded
  Running setup.py egg_info for package PIL
    WARNING: '' not a valid package name; please use only.-separated package names in setup.py
    
Installing collected packages: PIL
  Running setup.py install for PIL
    WARNING: '' not a valid package name; please use only.-separated package names in setup.py
    --- using frameworks at /System/Library/Frameworks
    building '_imaging' extension
    clang -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -IlibImaging -I/System/Library/Frameworks/Python.framework/Versions/2.7/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _imaging.c -o build/temp.macosx-10.8-intel-2.7/_imaging.o
    unable to execute clang: No such file or directory
    error: command 'clang' failed with exit status 1
    Complete output from command /usr/bin/python -c "import setuptools;__file__='/private/tmp/pip_build_root/PIL/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-AYrxVD-record/install-record.txt --single-version-externally-managed:
    WARNING: '' not a valid package name; please use only.-separated package names in setup.py

running install

running build

.
.
.
.

copying PIL/XVThumbImagePlugin.py -> build/lib.macosx-10.8-intel-2.7

running build_ext

--- using frameworks at /System/Library/Frameworks

building '_imaging' extension

creating build/temp.macosx-10.8-intel-2.7

creating build/temp.macosx-10.8-intel-2.7/libImaging

clang -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -IlibImaging -I/System/Library/Frameworks/Python.framework/Versions/2.7/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _imaging.c -o build/temp.macosx-10.8-intel-2.7/_imaging.o

unable to execute clang: No such file or directory

error: command 'clang' failed with exit status 1

----------------------------------------
Cleaning up…

你能帮我安装
PIL

我想你是在Mac上。看

如果您使用[自制][],则只需
brew即可安装PIL
安装pil
。然后可能需要添加安装目录(
$(brew
--将前缀)/lib/python2.7/site packages
)添加到PYTHONPATH中,或者将PIL目录本身的位置添加到名为
PIL.pth的文件中
您的任何网站包目录,包含以下内容:

/usr/local/lib/python2.7/site-packages/PIL
(假设
brew--prefix
/usr/local

或者,您可以从以下来源下载/构建/安装:

# download
curl -O -L http://effbot.org/media/downloads/Imaging-1.1.7.tar.gz
# extract
tar -xzf Imaging-1.1.7.tar.gz
cd Imaging-1.1.7
# build and install
python setup.py build
sudo python setup.py install
# or install it for just you without requiring admin permissions:
# python setup.py install --user
我刚刚在OSX 10.7.2上运行了上面的代码(使用XCode 4.2.1和系统) Python2.7.1),它构建得很好,尽管有可能 我的环境中的某些东西是非默认的

[自制]:“自制”

  • 如前所述,安装Xcode和Xcode命令行工具
  • 用枕头代替,因为PIL基本上已经死了。枕头是PIL的一个保持叉
  • 如果您同时安装了两个python,并且希望为Python3安装此选项:

    python3 -m pip install Pillow
    

    我也遇到了同样的问题,但通过安装
    pythondev
    ,问题得到了解决

    在安装PIL之前,请运行以下命令:

    sudo apt-get install python-dev
    
    然后安装PIL:

    pip install PIL
    

    在Mac OS X上,使用以下命令:

    sudo pip install https://effbot.org/media/downloads/Imaging-1.1.7.tar.gz
    
    这对我很有用:

    apt-get install python-dev
    apt-get install libjpeg-dev
    apt-get install libjpeg8-dev
    apt-get install libpng3
    apt-get install libfreetype6-dev
    ln -s /usr/lib/i386-linux-gnu/libfreetype.so /usr/lib
    ln -s /usr/lib/i386-linux-gnu/libjpeg.so /usr/lib
    ln -s /usr/lib/i386-linux-gnu/libz.so /usr/lib
    
    pip install PIL  --allow-unverified PIL --allow-all-external
    

    我通过在CentOS上使用
    sudo端口安装py27枕头

    实现了这一点:

    yum install python-imaging
    
    $ sudo apt-get install python-imaging
    $ sudo -H pip install pillow
    

    还有另一个Python包工具,名为。当有需要安装C++和其他不是纯Python的绑定的库时,Conda比PIP更受欢迎(我相信)。Conda在其安装中也包括pip,因此您仍然可以使用pip,但您也可以从Conda中获得好处


    默认情况下,Conda还安装、pil和许多其他库。我想你会喜欢的。

    我在安装过程中遇到了一些错误。以防万一有人也有这个。尽管如此,我已经坐在管理员用户,但不是根

    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 157, in makedirs
        mkdir(name, mode)
    OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/PIL'
    
    Storing debug log for failure in /Users/wzbozon/Library/Logs/pip.log
    
    添加“sudo”解决了问题,sudo起作用了:

    ~/Documents/mv-server: $ sudo pip install Pillow
    

    我从一次讨论中得到了答案:

    我试过了

    pip install --no-index -f http://dist.plone.org/thirdparty/ -U PIL
    

    使用apt install非常简单。使用此命令可以完成安装

    sudo apt-get install python-PIL
    

    试试这个:

    sudo pip install PIL --allow-external PIL --allow-unverified PIL
    

    对于Ubuntu,PIL不再工作了。我总是得到:

    未找到与PIL匹配的分发

    因此,请安装python映像:

    sudo apt-get install python-imaging
    
    (窗口)如果Pilow不工作,请尝试下载pil
  • 首先,您应该运行这个
    sudo apt get build dep python imaging
    ,它将提供您可能需要的所有依赖项

  • 然后运行
    sudo-apt-get-update&&sudo-apt-get-y-upgrade

  • 然后是
    sudo-apt-get-install-python-pip

  • 然后最后安装Pil
    pip安装枕头

  • $ sudo apt-get install python-imaging
    $ sudo -H pip install pillow
    

      现在,每个人都用枕头,一种友好的PIL叉子,盖在PIL上

      而不是:
      sudo-pip-install-pil

      Do:
      sudo pip安装枕

      $ sudo apt-get install python-imaging
      $ sudo -H pip install pillow
      

      在使用
      pip
      之前,在package manager上搜索。在Arch linux上,您可以通过pacman-S python2枕头获得PIL,我尝试了所有答案,但都失败了。 直接从官方网站获取源代码,然后构建安装成功

    • 访问站点
    • 单击“Python Imaging Library 1.1.7源代码工具包”下载源代码
    • tar xf Imaging-1.1.7.tar.gz
    • cd成像-1.1.7
    • sudo python setup.py安装

    • 您应该按照以下说明进行安装:

      安装

      pip install Pillow
      
      然后,只需在文件中导入

      from PIL import Image
      
      我正在使用windows。它对我有用

      注意


      枕头是Python图像处理的功能性替代品 图书馆。要使用枕头运行现有的PIL兼容代码,请 需要修改以从PIL导入成像模块 命名空间而不是全局命名空间

      i、 e.改变:

      导入图像

      致:

      从PIL导入图像


      对于Ubuntu,您可以使用
      apt install安装PIL

      对于Python 3,请使用:

      sudo apt install python3-pil
      
      对于Python 2,请使用:

      sudo apt install python-pil
      

      其中,
      pil
      应该是小写的,正如Clarkey252所指出的

      您安装了Xcode,然后又安装了Xcode的命令行工具吗?看起来你没有clang编译器。我在OSX Mavericks上尝试这个时遇到了一个
      clang
      错误,但我发现这个答案很有帮助:虽然这是一个有效且有用的答案,但它确实没有回答这个问题。对于我们这些正在重新构建旧项目的人来说,可能需要填充一个PIL依赖项,以便我们能够找到下一个将要打破的东西,我们实际上需要获得实际的依赖项(有时甚至需要获得一个特定的版本,有人构建了一个黑客)@Namey将现有的PIL代码移植到枕头上很容易。Pillow基于PIL代码,并已发展成为更好、更现代、更友好的PIL版本。@GiriB感谢您的更新。我的主要观点是,在很多情况下,您需要开始处理一些遗留的生产代码,其中有20个古老的依赖项,其中PIL可能就是其中之一,您需要调试一些东西来修复生产代码。在这种情况下,您肯定不希望为了调试生产环境中发生的单行错误而必须为连接到dev build上10个不同库的代码编写端口。希望能澄清这一点。我正在尝试使用一个使用
      导入图像的库。有没有办法让Pillow提供映像?在64位平台上,链接路径需要不同——例如/usr/lib/x86_64-linux-gnu/libfreetype.so。以获得更独立于体系结构的解决方案
      
      sudo apt install python3-pil
      
      sudo apt install python-pil