简体   繁体   English

导入pptx库python时出错

[英]error importing pptx library python

i want to import pptx but i'm using this我想导入 pptx 但我正在使用这个

import sys

sys.path.insert(0,'D:/apera/python27/python-pptx-0.5.6')

import pptx

but somehow it shows error like this但不知何故它显示了这样的错误

Traceback (most recent call last):
File "D:/apera/Workspace/Python scripting test 6/ppt.py", line 5, in <module>
import pptx
File "D:/apera/python27/python-pptx-0.5.6\pptx\__init__.py", line 15, in <module>
from pptx.api import Presentation  # noqa
File "D:/apera/python27/python-pptx-0.5.6\pptx\api.py", line 14, in <module>
from pptx.package import Package
File "D:/apera/python27/python-pptx-0.5.6\pptx\package.py", line 16, in <module>
from .parts.image import Image, ImagePart
 File "D:/apera/python27/python-pptx-0.5.6\pptx\parts\image.py", line 13, in <module>
 import Image as PIL_Image
ImportError: No module named Image

and when i want to install PIL it can't install for 64 bit.当我想安装 PIL 时,它无法安装 64 位。 Is there a ppt library that don't need PIL?有不需要PIL的ppt库吗?

remove the PIL package due to conflicts with Pillow and python-pptx 由于与Pillow和python-pptx冲突而删除PIL软件包

  • Delete the PIL directory located in C:\\Users\\user1\\AppData\\Local\\Continuum\\Anaconda\\Lib\\site-packages\\ or wherever your library is 删除位于C:\\ Users \\ user1 \\ AppData \\ Local \\ Continuum \\ Anaconda \\ Lib \\ site-packages \\或您的库所在的PIL目录

  • run pip install python-pptx to install Pillow 运行pip install python-pptx来安装Pillow

I had about the same issue. 我有同样的问题。 When I updated the pillow library (pretty easy to do with Anaconda which I use) the issue was gone. 当我更新枕头库(我使用的Anaconda相当容易)时,问题就消失了。

  1. Uninstall Pillow 卸载枕头

  2. Uninstall python-pptx 卸载python-pptx

  3. Install Pillow 安装枕

  4. Install python-pptx 安装python-pptx

Run above commands using "pip". 使用“ pip”运行以上命令。 This worked for me. 这对我有用。

I meet the same question My system is windowXP 32bit and python is 2.7.13 I just to degrade the version of pillow and python-pptx.我遇到了同样的问题我的系统是windowXP 32bit而python是2.7.13我只是为了降低枕头和python-pptx的版本。 It works for me pip install pillow==3.1.0 pip install python-pptx==0.5.5它对我有用 pip install Pillow==3.1.0 pip install python-pptx==0.5.5

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM