AttributeError: module 'ipython' has no attribute 'core' after upgrade
Fixes `AttributeError: module 'ipython' has no attribute 'core'` after upgrade: a file named `ipython.py` shadowing the package, or a partial install. Rename the shadowing file and reinstall cleanly. Not for import-path removals.
TL;DR
After an upgrade, import ipython is picking up a stray ipython.py file in your working directory or on sys.path instead of the real package, or the upgrade left a half-written install. Run python -c "import ipython; print(ipython.__file__)". If it points at a local file, rename that file. If it points at site-packages, uninstall ipython twice and reinstall once.
AttributeError: module 'ipython' has no attribute 'core' after upgradeUse this when
- Any
import IPythonorimport ipythonnow fails with this AttributeError after an upgrade. - The error appears in a directory where you have been writing scripts.
- The upgrade was interrupted or done with
--forceflags.
Not for this skill when
- The error names
ipython.core.displayspecifically. That is the removed re-export, a different fix. - The kernel dies instead of raising. That is a native crash.
Steps
- Ask python what it imported:
python -c "import ipython; print(ipython.__file__)". Verify: you see the actual path being loaded. - If the path is a local
ipython.pyor anipython/directory in your project, rename it to something non-colliding. Verify: the import now resolves to site-packages. - If the path is site-packages, the install is corrupt:
pip uninstall -y ipython, run it again to catch the second copy, thenpip install ipython. Verify:import IPython; IPython.__version__works. - Check for a second install shadowing the first:
pip list | grep -i ipythonshould show exactly one. Verify: no duplicates. - Restart the kernel and re-run. Verify: the AttributeError is gone in a fresh kernel.
Variant phrasings
module ipython has no attribute core
Short form. Shadowing file is the first check.
ipython import broken after pip upgrade
Upgrade-context phrasing. Partial install is the second suspect.
AttributeError ipython after update
General phrasing. Same two causes.
Compatibility: All IPython versions, pip installs. Shadowing can happen with any package, but the ipython.py filename is the classic.
Why it happens
Python puts the current working directory first on sys.path. A script or scratch file named ipython.py in the notebook's directory wins over the installed package, and the real package's submodules are then unreachable, producing this exact AttributeError.
Edge cases / pitfalls
- The shadowing file can also be
IPython.pyon case-insensitive filesystems. Search both casings. - A leftover
ipython.egg-linkor.pthfile can point at a deleted source checkout. Check site-packages for strays. - Renaming the file is not enough if a
__pycache__/ipython.*.pycremains and the source is gone. Clear the pycache too.
Provenance
Resolved from the public thread: https://vectle.com/posts/pst_2VN79jNexleBD4WuRmxIRQ