aficustree
aficustree

Reputation: 21

ImportError: No module named

I'm new to using VS Code for Python and can't seem to even start as there's some problem with the python path that only shows up in VSCode. The sample code works when keying in interactively to python3, pyCharm and calling via python3 test.py

#!/usr/bin/python
import sys
import geoip2.database
print(sys.path)  
reader = geoip2.database.Reader('/usr/share/GeoIP/GeoLite2-City.mmdb')
response = reader.city('78.31.107.133')
print (response.country.iso_code)

errors out with ImportError: No module named geoip2.database

it's definitely there via pip and in

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages

and sys.path prints

['', '/Library/Frameworks/Python.framework/Versions/3.6/lib/python36.zip', '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6', '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/lib-dynload', '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages', '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/setuptools-28.8.0-py3.6.egg', '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip-9.0.1-py3.6.egg']

Any ideas what i'm missing?

Upvotes: 1

Views: 1184

Answers (1)

aficustree
aficustree

Reputation: 21

turns out that i had a manually installed version conflicting with the version brought in via brew. I nuked the manually installed version and relinked the brew version and all is well in the world

Upvotes: 1

Related Questions