- Saved searches
- Use saved searches to filter your results more quickly
- ImportError: No module named exceptions #9065
- ImportError: No module named exceptions #9065
- Comments
- Python exceptions module install
- # ModuleNotFoundError: No module named ‘exceptions’ in Python
- # Common causes of the error
- # Check if the package is installed
- # Make sure your IDE is using the correct Python version
- # Install the package in a Virtual Environment
- # Try reinstalling the package
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
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
ImportError: No module named exceptions #9065
ImportError: No module named exceptions #9065
Comments
After installing Anaconda (64bit) on OSX 10.10 and trying to start ipython notebook via ipython notebook , I get the error below. The same problem exists just running ipython
$ ipython notebook Traceback (most recent call last): File "/Users/vertangelx/anaconda/envs/test/bin/ipython", line 4, in from IPython import start_ipython File "/Users/vertangelx/anaconda/envs/test/lib/python2.7/site-packages/IPython/__init__.py", line 47, in from .core.application import Application File "/Users/vertangelx/anaconda/envs/test/lib/python2.7/site-packages/IPython/core/application.py", line 24, in from IPython.core import release, crashhandler File "/Users/vertangelx/anaconda/envs/test/lib/python2.7/site-packages/IPython/core/crashhandler.py", line 28, in from IPython.core import ultratb File "/Users/vertangelx/anaconda/envs/test/lib/python2.7/site-packages/IPython/core/ultratb.py", line 116, in from IPython.utils import path as util_path File "/Users/vertangelx/anaconda/envs/test/lib/python2.7/site-packages/IPython/utils/path.py", line 19, in from IPython.utils.process import system File "/Users/vertangelx/anaconda/envs/test/lib/python2.7/site-packages/IPython/utils/process.py", line 19, in from ._process_posix import system, getoutput, arg_split, check_pid File "/Users/vertangelx/anaconda/envs/test/lib/python2.7/site-packages/IPython/utils/_process_posix.py", line 24, in import pexpect File "/Users/vertangelx/anaconda/envs/test/lib/python2.7/site-packages/pexpect/__init__.py", line 69, in from .exceptions import ExceptionPexpect, EOF, TIMEOUT ImportError: No module named exceptions
Why is this error happening on this particular system?
Below is the list of packages in my virtualenv
abstract-rendering 0.5.1 np110py27_0 defaults alabaster 0.7.6 py27_0 defaults anaconda 2.4.0 np110py27_0 defaults anaconda-client 1.1.0 py27_0 defaults appnope 0.1.0 py27_0 defaults appscript 1.0.1 py27_0 argcomplete 1.0.0 py27_1 defaults astropy 1.0.5 np110py27_1 defaults babel 2.1.1 py27_0 defaults backports.ssl-match-hostname 3.4.0.2 beautifulsoup4 4.4.1 py27_0 defaults bitarray 0.8.1 py27_0 blaze 0.8.3 blaze-core 0.8.3 py27_0 defaults bokeh 0.10.0 py27_0 defaults boto 2.38.0 py27_0 bottleneck 1.0.0 np110py27_0 defaults cdecimal 2.3 py27_0 cffi 1.2.1 py27_0 defaults clyent 0.4.0 py27_0 defaults colorama 0.3.3 py27_0 configobj 5.0.6 py27_0 cryptography 1.0.2 py27_0 defaults curl 7.45.0 0 defaults cython 0.23.4 py27_0 defaults cytoolz 0.7.4 py27_0 defaults datashape 0.4.7 np110py27_1 defaults decorator 4.0.4 py27_0 defaults docutils 0.12 py27_0 enum34 1.0.4 py27_0 fastcache 1.0.2 py27_0 flask 0.10.1 py27_1 freetype 2.5.5 0 defaults funcsigs 0.4 py27_0 gevent 1.0.1 py27_0 gevent-websocket 0.9.3 py27_0 greenlet 0.4.9 py27_0 defaults grin 1.2.1 py27_1 h5py 2.5.0 np110py27_4 defaults hdf5 1.8.15.1 2 defaults idna 2.0 py27_0 ipaddress 1.0.14 py27_0 defaults ipykernel 4.1.1 py27_0 defaults ipython 4.0.0 py27_1 defaults ipython-genutils 0.1.0 ipython-notebook 4.0.4 py27_0 defaults ipython-qtconsole 4.0.1 py27_0 defaults ipython_genutils 0.1.0 py27_0 defaults ipywidgets 4.1.0 py27_0 defaults itsdangerous 0.24 py27_0 jdcal 1.0 py27_0 jedi 0.9.0 py27_0 defaults jinja2 2.8 py27_0 defaults jpeg 8d 1 jsonschema 2.4.0 py27_0 jupyter 1.0.0 py27_0 defaults jupyter-client 4.1.1 jupyter-console 4.0.3 jupyter-core 4.0.6 jupyter_client 4.1.1 py27_0 defaults jupyter_console 4.0.3 py27_0 defaults jupyter_core 4.0.6 py27_0 defaults launcher 1.0.0 3 libpng 1.6.17 0 libtiff 4.0.6 0 defaults libxml2 2.9.2 0 libxslt 1.1.28 2 llvmlite 0.7.0 py27_3 defaults lxml 3.4.4 py27_0 markupsafe 0.23 py27_0 matplotlib 1.4.3 np110py27_3 defaults mistune 0.7.1 py27_0 defaults multipledispatch 0.4.8 py27_0 defaults nbconvert 4.0.0 py27_0 defaults nbformat 4.0.1 py27_0 defaults networkx 1.10 py27_0 defaults nltk 3.1 py27_0 defaults node-webkit 0.10.1 0 nose 1.3.7 py27_0 notebook 4.0.6 py27_0 defaults numba 0.21.0 np110py27_0 defaults numexpr 2.4.4 np110py27_0 defaults numpy 1.10.1 py27_0 defaults odo 0.3.4 py27_0 defaults openpyxl 2.2.6 py27_0 defaults openssl 1.0.2d 0 defaults pandas 0.17.0 np110py27_0 defaults path.py 8.1.2 py27_0 defaults patsy 0.4.0 np110py27_0 defaults pep8 1.6.2 py27_0 pexpect 3.3 py27_0 defaults pickleshare 0.5 py27_0 defaults pillow 3.0.0 py27_1 defaults pip 7.1.2 py27_0 defaults ply 3.8 py27_0 defaults psutil 3.2.2 py27_0 defaults ptyprocess 0.5 py27_0 defaults py 1.4.30 py27_0 defaults pyasn1 0.1.9 py27_0 defaults pyaudio 0.2.7 py27_0 pycosat 0.6.1 py27_0 pycparser 2.14 py27_0 pycrypto 2.6.1 py27_0 pycurl 7.19.5.1 py27_3 defaults pyflakes 1.0.0 py27_0 defaults pygments 2.0.2 py27_0 pyopenssl 0.15.1 py27_1 pyparsing 2.0.3 py27_0 pyqt 4.11.4 py27_0 defaults pytables 3.2.2 np110py27_0 defaults pytest 2.8.1 py27_0 defaults python 2.7.10 2 defaults python-dateutil 2.4.2 py27_0 python.app 1.2 py27_4 pytz 2015.6 py27_0 defaults pyyaml 3.11 py27_1 pyzmq 14.7.0 py27_1 defaults qt 4.8.7 1 defaults qtconsole 4.1.0 py27_0 defaults readline 6.2 2 redis 2.6.9 0 redis-py 2.10.3 py27_0 requests 2.8.1 py27_0 defaults rope 0.9.4 py27_1 scikit-image 0.11.3 np110py27_0 defaults scikit-learn 0.16.1 np110py27_0 defaults scipy 0.16.0 np110py27_1 defaults setuptools 18.4 py27_0 defaults simplegeneric 0.8.1 py27_0 defaults singledispatch 3.4.0.3 py27_0 defaults sip 4.16.9 py27_0 defaults six 1.10.0 py27_0 defaults snowballstemmer 1.2.0 py27_0 sockjs-tornado 1.0.1 py27_0 sphinx 1.3.1 py27_0 sphinx-rtd-theme 0.1.7 sphinx_rtd_theme 0.1.7 py27_0 spyder 2.3.7 py27_1 defaults spyder-app 2.3.7 py27_0 defaults sqlalchemy 1.0.9 py27_0 defaults sqlite 3.8.4.1 1 ssl_match_hostname 3.4.0.2 py27_0 statsmodels 0.6.1 np110py27_0 defaults sympy 0.7.6.1 py27_0 defaults tables 3.2.2 terminado 0.5 py27_1 defaults tk 8.5.18 0 toolz 0.7.4 py27_0 defaults tornado 4.2.1 py27_1 defaults traitlets 4.0.0 py27_0 defaults ujson 1.33 py27_0 unicodecsv 0.14.1 py27_0 defaults werkzeug 0.10.4 py27_0 wheel 0.26.0 py27_1 defaults xlrd 0.9.4 py27_0 defaults xlsxwriter 0.7.7 py27_0 defaults xlwings 0.4.1 py27_0 defaults xlwt 1.0.0 py27_0 yaml 0.1.6 0 zeromq 4.1.3 0 defaults zlib 1.2.8 0
The text was updated successfully, but these errors were encountered:
Python exceptions module install
Last updated: Feb 20, 2023
Reading time · 4 min
# ModuleNotFoundError: No module named ‘exceptions’ in Python
The Python «ModuleNotFoundError: No module named ‘exceptions'» occurs when we forget to install the python-docx module before importing it or install it in an incorrect environment.
To solve the error, install the module by running the pip install python-docx command.
Open your terminal in your project’s root directory and install the python-docx module.
Copied!# 👇️ in a virtual environment or using Python 2 pip install python-docx # 👇️ for python 3 (could also be pip3.10 depending on your version) pip3 install python-docx # 👇️ if you get permissions error sudo pip3 install python-docx pip install python-docx --user # 👇️ if you don't have pip in your PATH environment variable python -m pip install python-docx # 👇️ for python 3 (could also be pip3.10 depending on your version) python3 -m pip install python-docx # 👇️ using py alias (Windows) py -m pip install python-docx # 👇️ for Anaconda conda install -c conda-forge python-docx # 👇️ for Jupyter Notebook !pip install python-docx
After you install the python-docx package, the error should be resolved.
# Common causes of the error
The error occurs for multiple reasons:
- Not having the python-docx package installed by running pip install python-docx .
- Installing the package in a different Python version than the one you’re using.
- Installing the package globally and not in your virtual environment.
- Your IDE running an incorrect version of Python.
- Naming your module exception.py which would shadow the official module.
- Declaring a variable named exceptions which would shadow the imported variable.
If the error persists, get your Python version and make sure you are installing the package using the correct Python version.
For example, my Python version is 3.10.4 , so I would install the python-docx package with pip3.10 install python-docx .
Copied!pip3.10 install python-docx # 👇️ if you get permissions error use pip3 (NOT pip3.X) sudo pip3 install python-docx
Notice that the version number corresponds to the version of pip I’m using.
If the PATH for pip is not set up on your machine, replace pip with python3 -m pip :
Copied!# 👇️ make sure to use your version of Python, e.g. 3.10 python3 -m pip install python-docx
If the «No module named ‘exceptions'» error persists, try restarting your IDE and development server/script.
# Check if the package is installed
You can check if you have the python-docx package installed by running the pip show python-docx command.
Copied!# 👇️ check if you have python-docx installed pip show python-docx # 👇️ if you don't have pip set up in PATH python -m pip show python-docx
The pip show python-docx command will either state that the package is not installed or show a bunch of information about the package, including the location where the package is installed.
# Make sure your IDE is using the correct Python version
If the package is not installed, make sure your IDE is using the correct version of Python.
If you have multiple Python versions installed on your machine, you might have installed the python-docx package using the incorrect version or your IDE might be set up to use a different version.
For example, In VSCode, you can press CTRL + Shift + P or ( ⌘ + Shift + P on Mac) to open the command palette.
Then type «Python select interpreter» in the field.
Then select the correct python version from the dropdown menu.
Your IDE should be using the same version of Python (including the virtual environment) that you are using to install packages from your terminal.
# Install the package in a Virtual Environment
If you are using a virtual environment, make sure you are installing python-docx in your virtual environment and not globally.
You can try creating a virtual environment if you don’t already have one.
Copied!# 👇️ use correct version of Python when creating VENV python3 -m venv venv # 👇️ activate on Unix or MacOS source venv/bin/activate # 👇️ activate on Windows (cmd.exe) venv\Scripts\activate.bat # 👇️ activate on Windows (PowerShell) venv\Scripts\Activate.ps1 # 👇️ install python-docx in virtual environment pip install python-docx
If the python3 -m venv venv command doesn’t work, try the following 2 commands:
Your virtual environment will use the version of Python that was used to create it.
If the error persists, make sure you haven’t named a module in your project as exceptions.py because that would shadow the original python-docx module.
You also shouldn’t be declaring a variable named exceptions as that would also shadow the original module.
# Try reinstalling the package
If the error is not resolved, try to uninstall the python-docx package and then install it.
Copied!# 👇️ check if you have python-docx installed pip show python-docx # 👇️ if you don't have pip set up in PATH python -m pip show python-docx # 👇️ uninstall python-docx pip uninstall python-docx # 👇️ if you don't have pip set up in PATH python -m pip uninstall python-docx # 👇️ install python-docx pip install python-docx # 👇️ if you don't have pip set up in PATH python -m pip install python-docx
Try restarting your IDE and development server/script.
You can also try to upgrade the version of the python-docx package.
Copied!pip install python-docx --upgrade # 👇️ if you don't have pip set up in PATH python -m pip install python-docx --upgrade
If the error persists, I would suggest watching a quick video on how to use Virtual environments in Python.
This one is for using virtual environments (VENV) on Windows :
This one is for using virtual environments (VENV) on MacOS and Linux :
I wrote a book in which I share everything I know about how to become a better, more efficient programmer.