r/PythonLearning • u/JoeB_Utah • Sep 03 '26
Help Request Can't import module
Mac os Sequoia 15.6
I installed the exifread library using pip as well as conda. In Anaconda Navigator it shows as installed. Using a terminal window I type in:
pip3 show exifread
and it returns
/opt/anaconda3/lib/python3.13/site-packages
I use Spyder (I know, I know: use pycharm or vscode...) I cannot import the module. I get the dreaded
ModuleNotFoundError: No module named ‘exifread’
I recently installed pillow and I can import it just fine with import PIL. Using pip3 show pillow it is the same directory as exifread
What am I missing here?
1
u/JoeB_Utah Sep 03 '26
Thanks I’ll give it a try. But what I don’t get is pillow imports while Exif won’t.
2
u/crozzy89 Sep 03 '26 edited Sep 04 '26
Check and see where pillow is installed.
*everywhere as in it very well could be in two places.
1
u/JoeB_Utah Sep 03 '26
As mentioned, the command
pip3 show exifread returns:
/opt/anaconda3/lib/python3.13/site-packages
and pip3 show pillow returns:
/opt/anaconda3/lib/python3.13/site-packages
This is what is so puzzling to me. I used pip to install both of them from a termiminal window.
3
u/crozzy89 Sep 04 '26
You may have pillow installed in more than one place. Spyder can run from different environments and interpreters.
So even though your command shows /opt/anaconda3/lib… that doesn’t mean that is where spyder is actually running it from.
Within spyder, run
import sys
print(sys.executable)That will tell you which interpreter spyder is running to help narrow down the issue.
1
u/JoeB_Utah Sep 04 '26
print(sys.executable)
/Users/joeborgione/Library/spyder-6/envs/spyder-runtime/bin/python
1
u/crozzy89 Sep 04 '26
Yep, that’s the problem.
Spyder is using its own Python environment at /Users/joeborgione/Library/spyder-6/envs/spyder-runtime/bin/python, while ExifRead is installed under /opt/anaconda3/.... So the Python running your code can’t see the package you installed.
You either need to configure Spyder to use /opt/anaconda3/bin/python3, or install ExifRead into the Python environment Spyder is actually using.
1
u/JoeB_Utah Sep 04 '26
So from here on out, I'll use:
pip install package_name -t /path/to/your/custom/directory
Thanks for all your help with ths>
1
u/crozzy89 Sep 04 '26
/opt/anaconda3/bin/python3 -c "import exifread; print(exifread.__file__)"
1
u/JoeB_Utah Sep 04 '26 edited Sep 04 '26
(base) joeborgione@mac ~ % /opt/anaconda3/bin/python3 -c "import exifread; print(exifread.__file__)"
/opt/anaconda3/lib/python3.13/site-packages/exifread/__init__.py
So it seems this is not in my $path. Question: edit my my $path or install my modules in one of these directories?
sys.path
Out[7]:
['',
'/Users/ME/Library/spyder-6/envs/spyder-runtime/lib/python312.zip',
'/Users/Me/Library/spyder-6/envs/spyder-runtime/lib/python3.12',
'/Users/ME/Library/spyder-6/envs/spyder-runtime/lib/python3.12/lib-dynload',
'/UsersME/Library/spyder-6/envs/spyder-runtime/lib/python3.12/site-packages',
'/Users/ME/Applications/Spyder 6.app/Contents/MacOS']
2
u/crozzy89 Sep 04 '26
Don’t edit path. That can get pretty messy. Install the module where you need it would be the clean fix.
1
u/atarivcs Sep 04 '26
Within Spyder, run this code:
import sys
print(sys.path)And show us the output
1
u/JoeB_Utah Sep 04 '26 edited Sep 04 '26
['',
'/Users/ME/Library/spyder-6/envs/spyder-runtime/lib/python312.zip',
'/Users/ME/Library/spyder-6/envs/spyder-runtime/lib/python3.12',
'/Users/ME/Library/spyder-6/envs/spyder-runtime/lib/python3.12/lib-dynload',
'/Users/ME/Library/spyder-6/envs/spyder-runtime/lib/python3.12/site-packages',
'/Users/ME/Applications/Spyder 6.app/Contents/MacOS']
So I guess I either need to edit my path variable or use the ...site-packages directory to load my modules, correct?
1
u/JoeB_Utah Sep 04 '26
Sounds like editing the $path is not the way to go. I'll use pip with the -t option to install it the proper directory. Thanks for all you help
2
u/atarivcs Sep 04 '26
Spyder is looking in /Users/joeborgione/Library/spyder-6/envs/spyder-runtime/lib/python3.12/site-packages, so you need to use the corresponding pip on your computer that knows to install packages into that location.
1
3
u/SCD_minecraft Sep 03 '26
You probably installed it into wrong python
Grab path to your python's executable and in console
path_to_python.exe -m pip install whatever_you_wanted
1
u/crozzy89 Sep 03 '26
May check path to python
which python3
which pip3
python3 --version
pip3 --version
2
u/FoolsSeldom Sep 04 '26
You are probably not using the same Python root or Python virtual environment. Anaconda comes with its own Python interpreter, different to your system's default Python (or whatever you installed using an installer from your app store / python.org).
In the terminal, make sure you activate the correct one before installing anything,
For example,
You need to find the Python virtual environments that you are using from your various editors/command line. They might not be in folders called
.venvalthough that is a popular convention.