0

I am running in a venv that was created with python -m venv ./env and I have installed pylint and other necessary modules for my project.

when I run pylint utils.py I get the error

utils.py:5:0: E0401: Unable to import 'math' (import-error)

which is weird because it is finding other installed modules, but not something in the stdlib... I know there must be some kind of path issue somewhere but I can't figure out where it is.

my .pylintrc file contains the following hook which was necessary to get it to not throw errors when importing stuff form the venv

[MASTER]
init-hook='sys.path = ["./env/bin/python", "./env/lib/python3.7/site-packages/", "./"]'
Joff
  • 11,247
  • 16
  • 60
  • 103
  • I don't know why that hook should be needed, but it is cause of your problem. So maybe you should properly fix the original problem. – Klaus D. Mar 30 '19 at 05:43
  • oh, right. I put that there when I found this thread https://stackoverflow.com/questions/1899436/pylint-unable-to-import-error-how-to-set-pythonpath but that was when I didn't have pylint installed in the local env. Installing pylint locally with no hook did the trick – Joff Mar 30 '19 at 06:11

0 Answers0