Issues importing python-pptx on Linux (Ubuntu 17) - python

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.

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>

Related

Unable to locate package python-pytest

I had to reset my machine recently, and so have to re-install everything again.
I want to run a Python file using PyTest.
Bash Terminal:
me#PF2DCSXD:/mnt/c/Users/dabell/Documents/GitHub/workers-python/workers/composite_key/compositekey/tests$ pytest -s test_composite_key.py
Command 'pytest' not found, but can be installed with:
sudo apt install python-pytest
me#PF2DCSXD:/mnt/c/Users/dabell/Documents/GitHub/workers-python/workers/composite_key/compositekey/tests$ sudo apt install python-pytest
[sudo] password for danielbellhv:
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package python-pytest
I was able to install pip, following this post's Solution.
Please let me know if there is anything else I can add to post.
I had to first install pip, as here:
sudo apt-get update
sudo apt-get upgrade #Optional
sudo apt install python3-pip
Then
$ pip install pytest
Collecting pytest
Downloading pytest-6.2.5-py3-none-any.whl (280 kB)
|████████████████████████████████| 280 kB 621 kB/s
Collecting packaging
Downloading packaging-21.2-py3-none-any.whl (40 kB)
|████████████████████████████████| 40 kB 1.1 MB/s
Collecting iniconfig
Downloading iniconfig-1.1.1-py2.py3-none-any.whl (5.0 kB)
Collecting pluggy<2.0,>=0.12
Downloading pluggy-1.0.0-py2.py3-none-any.whl (13 kB)
Collecting py>=1.8.2
Downloading py-1.10.0-py2.py3-none-any.whl (97 kB)
|████████████████████████████████| 97 kB 1.1 MB/s
Collecting toml
Downloading toml-0.10.2-py2.py3-none-any.whl (16 kB)
Requirement already satisfied: attrs>=19.2.0 in /usr/lib/python3/dist-packages (from pytest) (19.3.0)
Collecting pyparsing<3,>=2.0.2
Downloading pyparsing-2.4.7-py2.py3-none-any.whl (67 kB)
|████████████████████████████████| 67 kB 1.1 MB/s
Installing collected packages: pyparsing, packaging, iniconfig, pluggy, py, toml, pytest
WARNING: The scripts py.test and pytest are installed in '/home/danielbellhv/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed iniconfig-1.1.1 packaging-21.2 pluggy-1.0.0 py-1.10.0 pyparsing-2.4.7 pytest-6.2.5 toml-0.10.2
Note:
$ pip install python-pytest
ERROR: Could not find a version that satisfies the requirement python-pytest (from versions: none)
ERROR: No matching distribution found for python-pytest

ImportError: libGL.so.1: cannot open shared object file: No such file or directory in CentOS

When I am using opencv in CentOS, shows this error:
ImportError: libGL.so.1: cannot open shared object file: No such file or directory
and I am install opencv like this:
[root#izbp19pke6x0v6ruecuy1yz pydolphin]# pip3 install opencv-python
Looking in indexes: http://mirrors.aliyun.com/pypi/simple/
Collecting opencv-python
Downloading http://mirrors.aliyun.com/pypi/packages/6d/80/10a9ae6fa0940f25af32739d1dc6dfdbbdc79af3f04c5ea1a6de4303cd54/opencv_python-4.4.0.46-cp36-cp36m-manylinux2014_x86_64.whl (49.5 MB)
|################################| 49.5 MB 10.2 MB/s
Requirement already satisfied: numpy>=1.13.3 in /usr/local/lib64/python3.6/site-packages (from opencv-python) (1.19.2)
Installing collected packages: opencv-python
Successfully installed opencv-python-4.4.0.46
what I am missing, what should I do to fix this problem?

Python3 ERROR:no module named telebot after pip installed it

python 3.5.2 // Ubuntu 16.04 LTS
I've installed pyTelegramBotAPI to code bots for telegram using this command:
pip instal pyTelegramBotAPI
Result:
Collecting pyTelegramBotAPI
Requirement already satisfied: six in /home/username/.local/lib/python2.7/site-packages (from pyTelegramBotAPI) (1.11.0)
Collecting requests (from pyTelegramBotAPI)
Using cached https://files.pythonhosted.org/packages/49/df/50aa1999ab9bde74656c2919d9c0c085fd2b3775fd3eca826012bef76d8c/requests-2.18.4-py2.py3-none-any.whl
Collecting certifi>=2017.4.17 (from requests->pyTelegramBotAPI)
Using cached https://files.pythonhosted.org/packages/7c/e6/92ad559b7192d846975fc916b65f667c7b8c3a32bea7372340bfe9a15fa5/certifi-2018.4.16-py2.py3-none-any.whl
Collecting chardet<3.1.0,>=3.0.2 (from requests->pyTelegramBotAPI)
Using cached https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl
Collecting idna<2.7,>=2.5 (from requests->pyTelegramBotAPI)
Using cached https://files.pythonhosted.org/packages/27/cc/6dd9a3869f15c2edfab863b992838277279ce92663d334df9ecf5106f5c6/idna-2.6-py2.py3-none-any.whl
Collecting urllib3<1.23,>=1.21.1 (from requests->pyTelegramBotAPI)
Using cached https://files.pythonhosted.org/packages/63/cb/6965947c13a94236f6d4b8223e21beb4d576dc72e8130bd7880f600839b8/urllib3-1.22-py2.py3-none-any.whl
Installing collected packages: certifi, chardet, idna, urllib3, requests, pyTelegramBotAPI
Then, I imported it into my source code:
import telebot
However, when I run the code I get the following error:
Traceback (most recent call last):
File "firstBot.py", line 1, in <module>
import telebot
ImportError: No module named 'telebot'
It mostly happens for Linux Users, because there is a preinstalled python(version 2.x) in the shell, When you install a new module or run your app with default python, it runs and serves by python2.x.
You should use pip3 when you installing it, or run your app by python3 app_main_file.py

Single pip command to install a tarball or zip as a wheel

I have been unable to find a single pip command to install from a repository (svn, git) or tarball/zip as a wheel. I'm using Python 2.7. For example, Genshi is only available from PyPI as tarball or zip. The package is installed as an egg:
~$virtualenv pve
New python executable in /Users/rjollos/pve/bin/python2.7
Also creating executable in /Users/rjollos/pve/bin/python
Installing setuptools, pip, wheel...done.
~$. pve/bin/activate
(pve) ~$pip install -U pip wheel setuptools
Collecting pip
Using cached pip-9.0.1-py2.py3-none-any.whl
Collecting wheel
Using cached wheel-0.29.0-py2.py3-none-any.whl
Collecting setuptools
Downloading setuptools-34.2.0-py2.py3-none-any.whl (389kB)
100% |████████████████████████████████| 393kB 810kB/s
Collecting packaging>=16.8 (from setuptools)
Using cached packaging-16.8-py2.py3-none-any.whl
Collecting six>=1.6.0 (from setuptools)
Using cached six-1.10.0-py2.py3-none-any.whl
Collecting appdirs>=1.4.0 (from setuptools)
Using cached appdirs-1.4.0-py2.py3-none-any.whl
Collecting pyparsing (from packaging>=16.8->setuptools)
Using cached pyparsing-2.1.10-py2.py3-none-any.whl
Installing collected packages: pip, wheel, six, pyparsing, packaging, appdirs, setuptools
Found existing installation: pip 8.0.2
Uninstalling pip-8.0.2:
Successfully uninstalled pip-8.0.2
Found existing installation: wheel 0.26.0
Uninstalling wheel-0.26.0:
Successfully uninstalled wheel-0.26.0
Found existing installation: setuptools 19.6.2
Uninstalling setuptools-19.6.2:
Successfully uninstalled setuptools-19.6.2
Successfully installed appdirs-1.4.0 packaging-16.8 pip-9.0.1 pyparsing-2.1.10 setuptools-34.2.0 six-1.10.0 wheel-0.29.0
$pip install --no-cache-dir genshi
Collecting genshi
Downloading Genshi-0.7.tar.gz (491kB)
100% |████████████████████████████████| 501kB 1.8MB/s
Installing collected packages: genshi
Running setup.py install for gens
$ls -ld pve/lib/python2.7/site-packages/Genshi*
drwxr-xr-x 9 rjollos staff 306 Feb 16 00:36 pve/lib/python2.7/site-packages/Genshi-0.7-py2.7.egg-info
As a workaround, I can create a wheel and then install the wheel:
(pve) ~$pip wheel --no-cache-dir --wheel-dir wheels genshi
Collecting genshi
Downloading Genshi-0.7.tar.gz (491kB)
100% |████████████████████████████████| 501kB 1.7MB/s
Building wheels for collected packages: genshi
Running setup.py bdist_wheel for genshi ... done
Stored in directory: /Users/rjollos/wheels
Successfully built genshi
(pve) ~$pip install wheels/Genshi-0.7-cp27-cp27m-macosx_10_12_x86_64.whl
Processing ./wheels/Genshi-0.7-cp27-cp27m-macosx_10_12_x86_64.whl
Installing collected packages: Genshi
Successfully installed Genshi-0.7
(pve) ~$ls -ld pve/lib/python2.7/site-packages/Genshi*
drwxr-xr-x 10 rjollos staff 340 Feb 16 00:43 pve/lib/python2.7/site-packages/Genshi-0.7.dist-info
Is there a way to build and install a wheel from a tarball/zip archive in a single pip command? There doesn't appear to be a --wheel option for pip install. There's an --only-binary option, but it will fail if a prebuilt wheel can't be found.

Error creating pytheapp for Ethereum on OSX

I am trying to install pyethapp on OSX but get an error right at the end ""python setup.py egg_info"". Any suggestions?
c233:json-server-api justinstaines$ pip install pyethapp
Collecting pyethapp
Downloading pyethapp-1.3.0-py2.py3-none-any.whl (334kB)
100% |████████████████████████████████| 337kB 1.2MB/s
Collecting statistics (from pyethapp)........
Collecting secp256k1 (from ethereum>=1.3.5->pyethapp)
Downloading secp256k1-0.12.1.tar.gz (144kB)
100% |████████████████████████████████| 153kB 2.3MB/s
Complete output from command python setup.py egg_info:
Your setuptools version (1.1.6) is too old to correctly install this package. Please upgrade to a newer version (>= 3.3).
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/rb/ydgvprfj6yg5q180740g1lpm0000gn/T/pip-build-KDbJvF/secp256k1/
Doh just realised
Your setuptools version (1.1.6) is too old to correctly install this package. Please upgrade to a newer version (>= 3.3).

Categories

Resources