Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportWarning: sys.meta_path is empty #8828

Closed
foxx opened this issue Sep 23, 2015 · 3 comments · Fixed by #8929
Closed

ImportWarning: sys.meta_path is empty #8828

foxx opened this issue Sep 23, 2015 · 3 comments · Fixed by #8929
Milestone

Comments

@foxx
Copy link

foxx commented Sep 23, 2015

In some situations, if you run unittests after importing IPython, it will cause the following errors to be flooded in 3.4;

sys:1: ResourceWarning: unclosed file <_io.TextIOWrapper name='/dev/null' mode='w' encoding='UTF-8'>
/home/vagrant/.virtualenvs/vagrant/lib/python3.4/importlib/_bootstrap.py:2127: ImportWarning: sys.meta_path is empty
/home/vagrant/.virtualenvs/vagrant/lib/python3.4/importlib/_bootstrap.py:2127: ImportWarning: sys.meta_path is empty
/home/vagrant/.virtualenvs/vagrant/lib/python3.4/importlib/_bootstrap.py:2127: ImportWarning: sys.meta_path is empty
/home/vagrant/.virtualenvs/vagrant/lib/python3.4/importlib/_bootstrap.py:2127: ImportWarning: sys.meta_path is empty
... repeated hundreds of times ...

There is a fixed bug in Python and another repo with the same problem.

If I remove the following import line, the problem goes away;

from IPython import start_ipython

Clearly there is something not quite right with the way IPython has been packaged, importing a function from a package should not result in any runtime execution differences.

@minrk
Copy link
Member

minrk commented Oct 8, 2015

Can you provide a complete example that reproduces the issue? The only interaction IPython has with sys.meta_path is adding import hooks when deprecated modules are imported. It never removes items from sys.meta_path.

@jakirkham
Copy link
Contributor

The sys.meta_path is an upstream issue in Python. It has been corrected in Python 3.5. I am not sure if a bugfix patch will be added for Python 3.4 or not. See more details here ( https://bugs.python.org/issue21049 ).

The ResourceWarning is caused by this line (

devnull = open(os.devnull, 'w')
) and can be fixed with this PR ( #8929 ).

@foxx
Copy link
Author

foxx commented Oct 28, 2015

Nice work, thanks guys!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants