1

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
Ganning Xu
  • 263
  • 4
  • 13
  • Does this answer your question? [Unable to import a module that is definitely installed](https://stackoverflow.com/questions/14295680/unable-to-import-a-module-that-is-definitely-installed) – Tomerikoo Nov 25 '20 at 17:34
  • @Tomerikoo I can try something in that link. But it looks my situation is more complicated. Something like I got several different library paths. Not sure what to do to clean that up or make them integrated? – Ganning Xu Nov 25 '20 at 22:31

1 Answers1

1

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

L W
  • 56
  • 1
  • 2