0

I'm having big trouble with getting an import to work so I am looking at other culprits. Check this out:

>>> import sys
>>> print(sys.path)
['', '/Users/pitosalas/miniconda3/lib/python37.zip', '/Users/pitosalas/miniconda3/lib/python3.7', '/Users/pitosalas/miniconda3/lib/python3.7/lib-dynload', '/Users/pitosalas/miniconda3/lib/python3.7/site-packages']
>>>

That initial empty string looks fishy to me. Is my sys.path broken? Where is it set up so I can fix it?

pitosalas
  • 10,286
  • 12
  • 72
  • 120
  • No, this is normal. It means that Python will look in the current working directory for modules first. If you are "having big trouble with getting an import to work" then you should *actually ask a question about that problem* - show the exact code that tries to do the import, show exactly what happens, and perhaps also the directory structure. But the most common problem here is that you tried for example to `import math` from the standard library, while also having a `math.py` in your project. – Karl Knechtel Jun 14 '20 at 00:02
  • 1
    Does this answer your question? [Where is Python's sys.path initialized from?](https://stackoverflow.com/questions/897792/where-is-pythons-sys-path-initialized-from) – Himanshu Jun 14 '20 at 00:02
  • @KarlKnechtel Thank you! I actually did: https://stackoverflow.com/questions/62366700/simple-case-of-init-py-and-import-giving-mysterious-module-not-found - although that's a simplification of my big trouble and even that makes no sense to me. Can you assist? – pitosalas Jun 14 '20 at 00:04

1 Answers1

2

Thats actually the path created by python to refer current directory. Theres no issue with that null string as python refers it current directory

Himanshu
  • 3,830
  • 2
  • 10
  • 29