I am trying to import the python pptx library in a python programm. I installed it using pip before, which gave me the following output:
Collecting python-pptx Downloading python-pptx-0.6.6.tar.gz (8.4MB) 100% |████████████████████████████████| 8.4MB 132kB/s Collecting Pillow>=2.6.1 (from python-pptx) Downloading Pillow-4.2.1-cp27-cp27mu-manylinux1_x86_64.whl (5.8MB) 100% |████████████████████████████████| 5.8MB 193kB/s Collecting XlsxWriter>=0.5.7 (from python-pptx) Downloading XlsxWriter-0.9.8-py2.py3-none-any.whl (137kB) 100% |████████████████████████████████| 143kB 1.2MB/s Collecting lxml>=3.1.0 (from python-pptx) Downloading lxml-3.8.0-cp27-cp27mu-manylinux1_x86_64.whl (6.8MB) 100% |████████████████████████████████| 6.8MB 166kB/s Collecting olefile (from Pillow>=2.6.1->python-pptx) Downloading olefile-0.44.zip (74kB) 100% |████████████████████████████████| 81kB 1.3MB/s Building wheels for collected packages: python-pptx, olefile Running setup.py bdist_wheel for python-pptx ... done Stored in directory: /home/clemens/.cache/pip/wheels/27/f8 /dc/181ed5439001413ee0c1c8794a06009c4c0b96f652401e2d20 Running setup.py bdist_wheel for olefile ... done Stored in directory: /home/clemens/.cache/pip/wheels/20/58 /49/cc7bd00345397059149a10b0259ef38b867935ea2ecff99a9b Successfully built python-pptx olefile Installing collected packages: olefile, Pillow, XlsxWriter, lxml, python-pptx Successfully installed Pillow-4.2.1 XlsxWriter-0.9.8 lxml-3.8.0 olefile-0.44 python-pptx-0.6.6
So this seems to be a success. But as I am trying to import the module using the following code:
try: from pptx import Presentation except Exception as e: print(e)
It says No module named 'pptx'
.
It must have something to do with Linux since the same code works just fine on windows and the module seems to be installed correctly. I am using Python 3.5.3.
Advertisement
Answer
Using pip install, you’ll install it for Python2, not for Python3. To make sure it gets installed for Python3, invoke pip from the interpreter, like this:
python3 -m pip install <package>