I uninstalled matplotlib
through Anaconda Prompt with conda remove matplotlib
and re-installed with conda install matplotlib
. This gave me this error:
(C: \Anaconda3) C: \Users\ John > conda install matplotlib[...]
ERROR conda.core.link: _execute_actions(337): An error occurred
while installing package 'defaults::matplotlib-2.0.2-np112py36_0'.
OSError(22, 'Invalid argument') Attempting to roll back.
OSError(22, 'Invalid argument')
I use a pyenv
virtual environment, whose path is /home/apk/.pyenv/versions/python-3-7-4
. When the environment is activated, pip
installs packages to /home/apk/.pyenv/versions/python-3-7-4/lib/python3.7/site-packages
. Therefore, in terminal, I set:
$ PYTHONPATH = /home/apk / .pyenv / versions / python - 3 - 7 - 4 / lib / python3 .7 /
After I did it, I checked in a python
shell.
$ python
Python 3.7 .4(
default, Feb 5 2020, 17: 11: 33)[GCC 5.5 .0 20171010] on linux
Type "help", "copyright", "credits"
or "license"
for more information. >>>
import sys >>>
sys.path['', '/home/apk/.pyenv/versions/3.7.4/lib/python37.zip', '/home/apk/.pyenv/versions/3.7.4/lib/python3.7', '/home/apk/.pyenv/versions/3.7.4/lib/python3.7/lib-dynload', '/home/apk/.pyenv/versions/python-3-7-4/lib/python3.7'] >>>
sys.executable '/home/apk/.pyenv/versions/python-3-7-4/bin/python'
Check you PATH
is correctly pointing to all Anaconda locations
import sys
sys.path
Check you PATH
is correctly pointing to all Anaconda locations
import sys
sys.path
A good way of directly debugging your problem would be to navigate to the following directory in ipython
C: \Anaconda3\ lib\ site - packages\ matplotlib
If this fails then you could then try
import matplotlib
matplotlib.__file__
Lastly, you can encounter the modulenotfounderror when you import a module that is not installed in your Python environment. ,The ModuleNotFoundError occurs when the module you want to use is not present in your Python environment. There are several causes of the modulenotfounderror:,A common error you may encounter when using Python is modulenotfounderror: no module named ‘matplotlib’. This error occurs when Python cannot detect the Matplotlib library in your current environment. This tutorial goes through the exact steps to troubleshoot this error for the Windows, Mac and Linux operating systems., Suf https://researchdatapod.com/author/soofyserial/ How to Solve Python ModuleNotFoundError: no module named 'pip'
The module’s name is incorrect, in which case you have to check the name of the module you tried to import. Let’s try to import the re module with a double e to see what happens:
import ree
import ree
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
ModuleNotFoundError Traceback(most recent call last)
1
import ree
ModuleNotFoundError: No module named 'ree'
import re
print(re.__version__)
You may want to import a local module file, but the module is not in the same directory. Let’s look at an example package with a script and a local module to import. Let’s look at the following steps to perform from your terminal:
mkdir example_package
cd example_package
mkdir folder_1
cd folder_1
vi module.py
import re
def print_re_version():
print(re.__version__)
Specifically, Python raises the ModuleNotFoundError if the module (e.g., py) cannot be found. If it can be found, there may be a problem loading the module or some specific files within the module. In those cases, Python would raise an ImportError.,The following video shows you how to import a function from another folder—doing it the wrong way often results in the ModuleNotFoundError:,If an import statement cannot import a module, it raises an ImportError. This may occur because of a faulty installation or an invalid path. In Python 3.6 or newer, this will usually raise a ModuleNotFoundError.,Python defines an error hierarchy, so some error classes inherit from other error classes. In our case, the ModuleNotFoundError is a subclass of the ImportError class.
You’ve just learned about the awesome capabilities of the py
library and you want to try it out, so you start your code with the following statement:
import py
This is supposed to import the Pandas library into your (virtual) environment. However, it only throws the following ImportError: No module named py
:
>>> import py
Traceback (most recent call last):
File "<pyshell#6>", line 1, in <module>
import py
ModuleNotFoundError: No module named 'py'
To fix this error, you can run the following command in your Windows shell:
$ pip install py
Understanding the “import” Statement
import py
You can also check this relationship using the issubclass()
built-in function:
>>> issubclass(ModuleNotFoundError, ImportError) True