Skip to content

Demonstration of a python ImportError with sys.path being correct (caused by os.chdir)

Notifications You must be signed in to change notification settings

fonfon/ImportError-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

This is a demonstration of an ImportError with sys.path being correct. The cause is os.chdir() followed by a package-intern import, see __main__.py. Importing the problematic module in __init__.py fixes the problem.

For me this ImportError was hard to debug and the available information rather sparse. The original issue is described at StackOverflow.

Usage

Clone the repository. Get the ImportError with:

python -m importerror

whereas this works (does not raise an ImportError):

python importerror/__main__.py

About

Demonstration of a python ImportError with sys.path being correct (caused by os.chdir)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages