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?

3
  • 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. Commented Jun 14, 2020 at 0:02
  • 1
    Does this answer your question? Where is Python's sys.path initialized from? Commented Jun 14, 2020 at 0:02
  • @KarlKnechtel Thank you! I actually did: stackoverflow.com/questions/62366700/… - although that's a simplification of my big trouble and even that makes no sense to me. Can you assist? Commented Jun 14, 2020 at 0:04

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.