Cannot find module PIL in Python - module

I am using:
Thonny Version 3.2.1
Python Version 3.7.0
PIP Version 19.2.3
Pillow Version 6.1.0
I am trying to import an image into my program and show it on the screen with the below code:
I get the error:
ModuleNotFoundError: No module named 'PIL'
backend.py, line 276
I believe the problem isn't my code, but instead an issue with the module Pillow not being found by Python?
Can anyone please help with a fix? I can clarify any info needed.
Additionally, I am new to Python and so go easy on me :-) Apologies if any of my terminology is incorrect.
I have tried:
1\ Removing PIL as per the install warning from Pillow (PIL Fork) install info. It was not present on my system. I did this through CMD.
2\ I always access CMD as the administrator.
3\ Updating all program versions above through CMD.
4\ Info I’ve found shows the above versions are compatible.
5\ Using the code help('modules') to show available modules, it does not show 'PIL' or 'Image', but does show 'pip'.
6\ Checked many forums for other fixes.
from PIL import Image
im = Image.open("JC.png")
im.show()

Related

plotnine is broken with matplotlib==3.6

I am getting the following error with plotnine==0.9 and matplotlib==3.6.
File "D:\Python\Python310\lib\site-packages\plotnine\stats\stat_density_2d.py", line 3, in <module>
import matplotlib._contour as _contour
ModuleNotFoundError: No module named 'matplotlib._contour'
If I downgrade matplotlib==3.5, the problem goes away.
It's discussed here and it's already fixed here Note that it's already merged to main.
It was due to a internal matplotlib call that is no longer supported and has been replaced.
So I guess you could choose between:
downgrade to mlp 3.5.3
install plotnine#main
till the next plotnine release.
Carlos's answer is correct. However if anybody else, like me, is uncertain of how to install plotnine#main, you can implement the fix rather easily:
Find the site_packages folder you python script uses. It usually is a subdirectory of the python version you are using, which can located reliably by trying to reinstall matplotlib or any other package you know you have access to, and checking the logs in the console. ex using python -m pip install matplotlib.
Go down into the site_packages/plotnine/stats directory and open up the stats_density_2d.py file in your editor of choice.
Apply & save the modifications made in the fix. Alternatively, overwrite the file with the one from the github.
ModuleNotFoundError: No module named 'matplotlib._contour'
Issues with matplotlib 3.6.1 and
plotnine 0.9.0
K.I.S.S.
in terminal:
pip show matplotlib #enables you to check version
pip install matplotlib==3.5 #revert and problem is resolved for now.
no more:
ModuleNotFoundError: No module named 'matplotlib._contour'
resolves issue for now that will stop progress...

Getting error #No module named 'obspy.clients.arclink' in the code for downloading earthquake data

I am trying to download earthquake data and using Obspy and Obspy DMT for the same. I have setup anaconda to work with VS code on Linux. I have created the base anaconda and a separate environment for ob spy. After running the program for earthquake data download, I am getting the error #No module named 'obspy.clients.arclink'. I am new to computational seismology and python in general. Please excuse for any mistakes.
This is the error showing:
ModuleNotFoundError: No module named 'obspy.clients.arclink'
Thank you
obspyDMT works with an older obspy version, you can downgrade via:
pip install obspy==1.2.2

Unable to import required dependencies: numpy

I'm trying to build a visual dashboard in VS Code using dash. But I can't get past this error I'm getting:
Original error was: DLL load failed: The specified module could not be
found. File "C:\Users\ko14Z57\plots.py", line 1, in
import pandas as pd
Exception has occurred: ImportError Unable to import required
dependencies: numpy:
I'm using python 3.6.13 but I've tried this with python 3.9 and 3.8. I also tried installing\uninstalling numpy and pandas. I'm using Anaconda for my package management. Any help would be really appreciated!
in vscode from view>command palette write 'select your default profile' the select 'Command Prompt' or 'cmd.exe'
Assuming that Bas may be right, and you're missing the Microsoft C++ compiler. Try installing Microsoft's "C/C++ Extension Pack": https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools-extension-pack . You can find it in VSCode by clicking the extensions icon at the left side and searching "cpptools".
Since I'm using conda, I updated conda and then updated all of my packages and that worked.
conda update conda
conda update --all
Note: I'm on Python 3.9 on a Windows machine.
Probably unnecessary, but I also added the interpreter path to my launch.json file:
"python": "C:\\Users\\<username>\\Anaconda3\\python.exe"

Error in Power BI while importing pandas library in python scrip

Below are the mentioned error while importing pandas library in Power BI in python script.
Details: "ADO.NET: Python script error.
C:\USERS\YADAVP\ANACONDA3\lib\site-packages\numpy\__init__.py:140: UserWarning: mkl-service package failed to import, therefore Intel(R) MKL initialization ensuring its correct out-of-the box operation under condition when Gnu OpenMP had already been loaded by Python process is not assured. Please install mkl-service package, see http://github.com/IntelPython/mkl-service
from . import _distributor_init
Traceback (most recent call last):
File "PythonScriptWrapper.PY", line 2, in <module>
import os, pandas, matplotlib
File "C:\USERS\YADAVP\ANACONDA3\lib\site-packages\pandas\__init__.py", line 17, in <module>
"Unable to import required dependencies:\n" + "\n".join(missing_dependencies)
ImportError: Unable to import required dependencies:
numpy:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy c-extensions failed.
- Try uninstalling and reinstalling numpy.
- If you have already done that, then:
1. Check that you expected to use Python3.7 from "C:\USERS\YADAVP\ANACONDA3\python.exe",
and that you have no directories in your PATH or PYTHONPATH that can
interfere with the Python and numpy version "1.18.1" you're trying to use.
2. If (1) looks fine, you can open a new issue at
https://github.com/numpy/numpy/issues. Please include details on:
- how you installed Python
- how you installed numpy
- your operating system
- whether or not you have multiple versions of Python installed
- if you built from source, your compiler versions and ideally a build log
- If you're working with a numpy git repository, try `git clean -xdf`
(removes all files not under version control) and rebuild numpy.
Note: this error has many possible causes, so please don't comment on
an existing issue about this - open a new one instead.
Original error was: DLL load failed: The specified module could not be found.
What is the resolution to sort this kind of error in Power BI?
Forget Anaconda and use WinPython.
I tried Anaconda for days with all the workarounds available in StackOverflow and other forums, and they took me nowhere.
Then I tried WinPython, and it worked immediately. Of course, you will need to change the PowerBI options accordingly.
To install WinPython: https://github.com/winpython/winpython
To change the detected Python home directory: https://learn.microsoft.com/en-us/power-bi/connect-data/desktop-python-scripts#enable-python-scripting
If you consider my answer, you won't need to downgrade Python, PBI, or anything else.
I had the same error. Unfortunately, PowerBI wont work with Jupyter Notebook Python.
So you have to install a "normal" Python: https://www.python.org/downloads/
And configure the Python you want to use in PowerBI and install your needed Python libraries via pip
Edit: Please use Python 3.8 because 3.9 doesnt support NumPy for now

Missing package to enable rendering OpenAI Gym in Colab

I'm attempting to render OpenAI Gym environments in Colab via a Mac using the StarAI code referenced in previous questions on this topic. However, it fails. The key error (at least the first error) is shown in full below, but the import part seems to be "Please install xdpyinfo!"
PyPI doesn't have xdpyinfo. What is it and how do I install it?
Full error message:
482780428160 abstractdisplay.py:151] xdpyinfo was not found, X start can not be checked! Please install xdpyinfo!
I've seen the same error, and solved it by installing x11-utils package which includes xdpyinfo command.
!apt-get install x11-utils