I pip-installed the module absl
, and I'm able to successfully import it in the interpreter, but when I run a script that imports it, I get the error ImportError: No module named absl
. What gives?
I know this post reports the same error, but since this isn't in regards to a package I created (it's part of Google's Python certificate-transparency tools ), I don't believe the problem concerns shadowing a filename.
Verify what python interpreter is running your script
import sys
print(sys.executable)
Also verify if for whatever reason your python interpreter is runing from a virtualenv
import sys
if hasattr(sys, 'real_prefix'):
Make sure the interpreter | venv that is running your script; is the one the absl package was installed for
I was using someone else's script, whose shebang was #!/usr/bin/env python
. However, my default python
version was 2.7, whereas I had downloaded the absl module for python3 via pip3. Once I changed the shebang to #!/usr/bin/env python3
, Python was able to find the absl module.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.