Looks these two modules are installed:
ganningxu#Gannings-iMac:~$ pip3 list |grep -i ezgmail
EZGmail 2020.9.29
ganningxu#Gannings-iMac:~$ pip3 list |grep -i twilio
twilio 6.35.5
But I can't get them imported in python3:
ganningxu#Gannings-iMac:~/python_prog/texting$ python3
Python 3.9.0 (default, Nov 21 2020, 14:55:42)
[Clang 12.0.0 (clang-1200.0.32.27)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ezgmail
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'ezgmail'
>>> import twilio
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'twilio'
>>>
What could be wrong with my python3 environment to cause this?
Update:
Looks like ezgmail was installed into /Library/Python/3.7/site-packages.
Yet, it looks the above path was not among those in sys.path.
ganningxu#Gannings-iMac:/Library/Python/3.7/site-packages$ python3
Python 3.9.0 (default, Nov 21 2020, 14:55:42)
[Clang 12.0.0 (clang-1200.0.32.27)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print(sys.path)
['', '/usr/local/Cellar/python#3.9/3.9.0_2/Frameworks/Python.framework/Versions/3.9/lib/python39.zip', '/usr/local/Cellar/python#3.9/3.9.0_2/Frameworks/Python.framework/Versions/3.9/lib/python3.9', '/usr/local/Cellar/python#3.9/3.9.0_2/Frameworks/Python.framework/Versions/3.9/lib/python3.9/lib-dynload', '/usr/local/lib/python3.9/site-packages']
Also, the confusing part is some libs were installed into /Library/Python/3.7/site-packages, as:
ganningxu#Gannings-iMac:/Library/Python/3.7/site-packages$ ls
EZGmail-2020.9.29.dist-info filelock.py
__pycache__ importlib_metadata
_distutils_hack importlib_metadata-1.5.0.dist-info
appdirs-1.4.3.dist-info pkg_resources
appdirs.py setuptools
distlib setuptools-50.3.2.dist-info
distlib-0.3.0.dist-info wheel
distutils-precedence.pth wheel-0.35.1.dist-info
easy_install.py zipp-3.0.0.dist-info
ezgmail zipp.py
filelock-3.0.12.dist-info
But some others were installed into the similar path in my homedir:
ganningxu#Gannings-iMac:~/Library/Python/3.7/lib/python/site-packages$ ls
Django-2.1.5.dist-info multidict
IMAPClient-2.1.0.dist-info multidict-4.7.5.dist-info
PIL nose
Pillow-8.0.0.dist-info nose-1.3.7.dist-info
Pillow-8.0.1.dist-info oauth2client
PyJWT-1.7.1.dist-info oauth2client-4.1.3.dist-info
SpeechRecognition-3.8.1.dist-info openpyxl
__pycache__ openpyxl-2.6.2.dist-info
_distutils_hack pdfkit
aiohttp pdfkit-0.6.1.dist-info
aiohttp-3.6.2.dist-info pip
apiclient pip-20.2.4.dist-info
async_timeout pkg_resources
async_timeout-3.0.1.dist-info psycopg2
attr psycopg2-2.8.6.dist-info
attrs-19.3.0.dist-info pyasn1
beautifulsoup4-4.8.2.dist-info pyasn1-0.4.8.dist-info
bs4 pyasn1_modules
cachetools pyasn1_modules-0.2.8.dist-info
cachetools-4.0.0.dist-info pygame
certifi pygame-1.9.6.dist-info
certifi-2019.11.28.dist-info pyperclip
chardet pyperclip-1.8.1.dist-info
chardet-3.0.4.dist-info pytz
coronavirus pytz-2019.3.dist-info
coronavirus-1.1.0.dist-info requests
distutils-precedence.pth requests-2.23.0.dist-info
django requests_file-1.5.1.dist-info
easy_install.py requests_file.py
et_xmlfile rfc3986
et_xmlfile-1.0.1.dist-info rfc3986-1.4.0.dist-info
google rsa
google_api_python_client-1.7.11.dist-info rsa-4.0.dist-info
google_auth-1.11.2-py3.8-nspkg.pth scrape
google_auth-1.11.2.dist-info scrape-0.10.1.dist-info
google_auth_httplib2-0.0.3.dist-info selenium
google_auth_httplib2.py selenium-3.141.0.dist-info
googleapiclient setuptools
h11 setuptools-50.3.2.dist-info
h11-0.9.0.dist-info simpleaudio
h2 simpleaudio-1.0.4.dist-info
h2-3.2.0.dist-info sniffio
hpack sniffio-1.1.0.dist-info
hpack-3.0.0.dist-info soupsieve
hstspreload soupsieve-2.0.dist-info
hstspreload-2020.5.19.dist-info speech_recognition
httplib2 spotipy
httplib2-0.17.0.dist-info spotipy-2.11.2.dist-info
httpx tekore
httpx-0.12.1.dist-info tekore-1.7.0.dist-info
hyperframe tldextract
hyperframe-5.2.0.dist-info tldextract-3.1.0.dist-info
idna twilio
idna-2.9.dist-info twilio-6.35.5.dist-info
image uritemplate
image-1.5.33.dist-info uritemplate-3.0.1.dist-info
imapclient urllib3
jdcal-1.4.1.dist-info urllib3-1.25.8.dist-info
jdcal.py virtualenv
jwt virtualenv-20.0.4.dist-info
lxml yarl
lxml-4.5.0.dist-info yarl-1.4.2.dist-info
I think you are working on two different python interpreters. You can check the version you use in the shell by typing python3 -v on mac. You could also install anaconda and setup a new enviroment to make sure everything is installed
Related
Why am I getting the following import error when I try to import eventlet's SSL module:
ModuleNotFoundError: No module named 'OpenSSL.tsafe'
Is eventlet's OpenSSL not compatible with recent versions of pyOpenSSL?
Reproduction Steps
Using the following Pipenv:
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
[packages]
pyOpenSSL = "*"
eventlet = "*"
[requires]
python_version = "3"
Create a pipenv using that file:
$ pipenv install
Creating a virtualenv for this project…
Pipfile: /tmp/Pipfile
Using /usr/local/bin/python3.8 (3.8.3) to create virtualenv…
...
Successfully created virtual environment!
...
Now import eventlet.green.OpenSSL.SSL:
$ pipenv run python
Python 3.8.3 (default, Jun 29 2020, 18:02:49)
[GCC 8.3.1 20190311 (Red Hat 8.3.1-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from eventlet.green.OpenSSL import SSL
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/myuser/.local/share/virtualenvs/tmp-XVr6zr33/lib/python3.8/site-packages/eventlet/green/OpenSSL/__init__.py", line 3, in <module>
from . import tsafe
File "/home/myuser/.local/share/virtualenvs/tmp-XVr6zr33/lib/python3.8/site-packages/eventlet/green/OpenSSL/tsafe.py", line 1, in <module>
from OpenSSL.tsafe import *
ModuleNotFoundError: No module named 'OpenSSL.tsafe'
>>>
After digging around a while, it looks like eventlet indeed does not currently work with the latest 20.0.0 PyOpenSSL package which was released four days ago as of the time of this post. I filed an issue with eventlet:
https://github.com/eventlet/eventlet/issues/671
Until eventlet is updated, we'll have to pin PyOpenSSL to the previous 19.1.0 release (per the Pipfile from the question):
pyOpenSSL = "==19.1.0"
I am using python3 and have installed tensorflow-gpu using:
pip3 install tensorflow-gpu==1.13.1
And have checked that it is installed by:
pip3 show tensorflow-gpu
Name: tensorflow-gpu
Version: 1.13.1
Summary: TensorFlow is an open source machine learning framework for
everyone.
Home-page: https://www.tensorflow.org/
Author: Google Inc.
Author-email: opensource#google.com
License: Apache 2.0
Location: /usr/lib64/python3.6/site-packages
Requires: tensorflow-estimator, keras-applications, termcolor, absl-py, six,
astor, protobuf, wheel, keras-preprocessing, gast, grpcio, numpy,
tensorboard
Required-by:
but when I do the following it gives me an error:
user:/home/mydirectory # python3
Python 3.6.5 (default, Mar 31 2018, 19:45:04) [GCC] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.6/site-packages/tensorflow/__init__.py", line 24,
in <module>
from tensorflow.python import pywrap_tensorflow # pylint:
disable=unused-import
File "/usr/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 25, in <module>
from tensorflow.python.platform import self_check
ModuleNotFoundError: No module named 'tensorflow.python.platform'
I see from the error that its looking for tensorflow in directory
/usr/lib/python3.6/site-packages/tensorflow
But pip indicates that its installed at
/usr/lib64/python3.6/site-packages
How can I fix this issue?
Please follow below steps..
0) please login with root permission or sudo and write this command in terminal
1)pip3 install tensorflow-gpu==1.13.1
2)pip3 --version
pip 8.1.1 from /usr/lib/python3/dist-packages (python 3.5)
3)shekh#shekh:~$ python3
Python 3.5.2 (default, Nov 12 2018, 13:43:14)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
https://www.tensorflow.org/install/pip
See https://github.com/tensorflow/tensorflow/issues/374
Are you opening the terminal from within the tensorflow directory?
"Actually I had this issue because I was trying to import tensorflow from a python session inside the tensorflow repo folder, going to some other folder and starting python and importing tensorflow worked for me."
I also had this error and it was solved with this command
python2:
PYTHONPATH="${PYTHONPATH}:/usr/local/lib/python2.7/dist-packages/"
export PYTHONPATH
python3:
PYTHONPATH="${PYTHONPATH}:/usr/local/lib/python3.6/dist-packages/"
export PYTHONPATH
I encountered a similar error on a Windows 10 system.
There, I had a second tensorflow install under AppData\Roaming\Python\.... This install was likely a product of some previous work that I did not clean up properly, so for me, removing the content of the site-packages directory solved the issue. After that I could import tensorflow without any problems.
When trying to install pgadmin4 in desktop mode on my Ubuntu system, I received a ModuleNotFoundError for _ctypes.
I did some research and found that _ctypes requires the libffi-dev package to be installed. However it seems that libffi-dev and thus _ctypes was installed for Python 2.7, when I run import ctypes it seems to work:
$ python2
Python 2.7.15+ (default, Nov 27 2018, 23:36:35)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes
>>>
When I try to do the same for Python 3.7, it doesn't work:
$ python
Python 3.7.3 (default, Jun 21 2019, 12:46:58)
[GCC 7.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.7/ctypes/__init__.py", line 7, in <module>
from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'
How could I add the module _ctypes to my Python 3.7 configuration?
If you install python from source file, you have to install some required packages manually as mentioned in https://superuser.com/questions/1412975/how-to-build-and-install-python-3-7-x-from-source-on-debian-9-8.
Actually you are supposed to see some errors after make due to libffinot found as shown in the screenshot below. However, you can still run make install despite the error. When you open python after the installation and import the module, it then gives you such error.
To solve this problem, you can install the dependent package i.e libffi or libffi-devel(redhat) prior to ./configure, make and make install as mentioned in:
Package libffi was not found in the pkg-config search path REDHAT6.5 and
https://bugs.python.org/issue31652.
I'm using Python 3.6.4 with pillow 5.0.0, through Anaconda.
Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 10:22:32) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from PIL import Image
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "F:\Anaconda2\envs\py3\lib\site-packages\PIL\Image.py", line 58, in <module>
from . import _imaging as core
ImportError: DLL load failed: The specified module could not be found.
Probably the same as this question. But that was 10 months ago and the answer says it was fixed with Python 3.6.1.
If you're using the Anaconda distribution, try removing it with Conda:
conda uninstall pillow
and installing it using pip:
pip install pillow
You can test that it's working:
python -c "from PIL import Image"
Here is the output of pip3 freeze:
Chases-MBP:/ chasehippen$ pip3 freeze
certifi==2018.1.18
chardet==3.0.4
flake8==3.5.0
get==0.0.39
idna==2.6
mccabe==0.6.1
pew==1.1.2
pipenv==9.0.3
post==0.0.26
public==0.0.65
pycodestyle==2.3.1
pyflakes==1.6.0
query-string==0.0.28
request==0.0.26
requests==2.18.4
six==1.11.0
urllib3==1.22
virtualenv==15.1.0
virtualenv-clone==0.2.6
And here's what happens when I try to import requests or urllib3:
Chases-MBP:/ chasehippen$ python3
Python 3.6.4 (v3.6.4:d48ecebad5, Dec 18 2017, 21:07:28)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'requests'
>>> import urllib3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'urllib3'
I reinstalled python 3 via homebrew twice, I don't understand why it won't let me import the modules?
If I run python import urllib2, that works fine, but only urllib3 fails.
Here are the outputs of where
Chases-MBP:~ chasehippen$ which pip3
/Library/Frameworks/Python.framework/Versions/3.6/bin/pip3
Chases-MBP:~ chasehippen$ which python3
/Library/Frameworks/Python.framework/Versions/3.6/bin/python3
All of the resources I saw were saying I need to add the paths to .profile or .bashrc, but on mac, or at least mine, it's .bash_profile. I had to add "export PYTHONPATH="${PYTHONPATH}/Library/Frameworks/Python.framework/Versions/3.6/bin/":/usr/local/lib/python3.6/site-packages" to that file, and now importing works like a charm.
For anyone in the future reading this for an answer to using python3 on a mac, the file is ~/bash_profile , adding the line above in place of the default line that python 3 puts in there lets you use all of the modules that are installed in site-packages instead of bin