On Raspberry Pi3B+, I have a program that uses pytz. In Thonny the statement import pytz works fine, but when I try to run the program at startup, in /etc/rc.local with python3 it can't do the import. When I remove the use of pytz in the program, it runs ok at startup. pytz was installed using pip3.
Related
I have some old code I'm trying to use which uses httplib2 Python lib. The same exact code works fine on Linux (e.g. Raspberry Pi).
I have used pip to uninstall the httplib2 lib and pip3 to re-install.
Here's what "pip list" (or "pip3 list") shows:
C:\Users\g7847>pip list
Package Version
----------------------- ---------
bcrypt 3.2.0
cachetools 4.2.4
certifi 2021.5.30
cffi 1.15.0
chardet 4.0.0
cryptography 36.0.0
cycler 0.10.0
google-auth 2.3.3
google-auth-httplib2 0.1.0
httplib2 0.20.2
idna 2.10
kiwisolver 1.3.1
matplotlib 3.4.2
numpy 1.21.0
paramiko 2.8.1
Pillow 8.3.1
pip 21.3.1
pyasn1 0.4.8
pyasn1-modules 0.2.8
pycparser 2.21
PyNaCl 1.4.0
pyparsing 2.4.7
python-dateutil 2.8.2
requests 2.25.1
requests-http-signature 0.2.0
rsa 4.8
setuptools 57.1.0
six 1.16.0
urllib3 1.26.6
wheel 0.36.2
C:\Users\g7847>
and yet:
C:\Users\g7847>python3 sshConnect.py
Traceback (most recent call last):
File "C:\Users\g7847\sshConnect.py", line 12, in <module>
import httplib2
ModuleNotFoundError: No module named 'httplib2 '
This is the import section at the beginning. The only library that is complained about is httlib2.
import json
import time
import subprocess
import datetime
import base64
import sys
import os
import getpass
import errno
import re
import string
import httplib2
pip and pip3 are not the same.
pip will use one of your Python versions depending on what exactly is first in the system PATH variable, whereas with pip3 you can be sure that the module will be installed in python3 library.
So, could you double check if the module is actually installed in the python3 library ?
If the module really is installed in python3 library, you could check if the PATH variable is correct.
(You can check the PATH by using the following : Reference)
The httplib2 library is part of the standard library in Python 3.
import httplib ImportError: No module named httplib
is it installed on version 2.x?
pip2 install httplib2
I still don't really know what was going on. I decided for other reasons to switch to the requests library rather than httplib2. My program runs OK inside Idle and I also made Windows EXE of it using pyinstaller on the command line. I thought I was having trouble running it directly as a Python program but I just checked it and it's fine.
One thing that MIGHT have been an issue is that I also have been using WSL (Ubuntu) in Windows and had installed httplib2 over there. I really don't know. I did uninstall that just in case but I'm not using httplib2 any more anyway.
There is a weird issue that happens if you run the Windows 3.9 installer from Python.org. If you subsequently try to run Python, then the Windows Store opens and you can't do anything except install that. So I uninstalled and reinstalled everything a few times but the last time it was just the Windows Store version as it seemed fairly insistent.
I'm currently doing
pip3 install reportlab
and that works fine. However in my script I have a
from reportlab.pdfgen import canvas
Running my script results in a module reportlab not found. To run the script I am using python3 name_of_script.py, but python name_of_script.py also doesn't work. Any ideas?
Trying to import python module fake_useragent
Command prompt stating that it has already been installed.
Anybody knows how come I still cannot import the fake_useragent module in python even though I have already installed it?
Thank you very much, I have solved the problem. I have tried to uninstall and reinstall the module but it still did not work. I tried to use Jupyter Notebook as well as Pycharm to import the module but I could not. Eventually, I tried to import the module using IDLE, which is the default IDE which comes with downloading and installing Python from python.org and I was successful. Therefore, I suspected that I had accidentally installed two versions of Python on my computer. The problem is that I have already installed Python 3 inside my computer. However, on top of that, I have also installed the Anaconda package, which also installs its own version of Python 3. However, when I use pip to install the fake-useragent module, I am installing it for the original python version. Therefore, when I use Jupyter notebook which is part of the Anaconda package, I could not input the module. I could not import it for Pycharm as well since I used the Anaconda interpreter as Pycharm's default interpreter. After I have uninstalled Anaconda and changed the default interpreter for Pycharm under settings back to the original version of Python which I have installed, I'm able to import the fake-useragent in python.
I am completely new to programming and Linux OS.
In my Linux machine, I edited my bashrc so that when I type python, it calls python3. I have python 3.4 and python 3.5.2 installed. Recently, I install this module pyperclip using pip3 install.
My problem is when at python 3.5.2, the pyperclip module couldn't be found, I couldn't import it at terminal. When at python 3.4, I get to import the module.
Being completely new to Linux, I have no idea how to access the "pyperclip" module via python 3.5.2
I bought this book "Automate the Boring Stuff with Python." and the projects are really interesting.
Is it advisable to have more than one version of Python in my machine? Can I just use only one? How to I import pyperclip module in python 3.5.2?
Try this in Terminal.
pip3 install
pip3 install setuptools
pip3 install pyperclip
However you may need to have downloaded the zip pyperclip module first. Mine was in my Downloads directory on my Mac before I ran the previous three pip lines in Terminal.
I installed matplotlib with package manager in Linux Mint 17.1. When I type import matplotlib in python3 terminal, everything works fine. However, when I create virtualenv, and then I run this command, Python cannot find this module. Can I somehow force my virtual environment to see it is already installed?