I've been trying to import the psutil module from cygwin (as a Linux alternative for Windows 7). The installation worked, though.
When re-installed, it showed:
Requirement already satisfied: psutil in /usr/local/lib/python3.8/site-packages (0.1.3)
But when imported, it gave:
>>> import psutil
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.8/site-packages/psutil/__init__.py", line 61, in <module>
raise ImportError('no os specific module found')
ImportError: no os specific module found
I tried a couple of things:
Upgrading the pip and psutil itself, using these commands:
python3 -m pip install --upgrade pip
pip3 install --upgrade psutil
so the current version:
Requirement already satisfied: pip in /usr/local/lib/python3.8/site-packages (21.2.4)
Requirement already satisfied: psutil in /usr/local/lib/python3.8/site-packages (0.1.3)
Made sure that packages are installed only in the python 3.8.10 version (I have multiple versions of python installed, so I figured the inconsistency of versions may be causing the problem. But still, it didn't help).
Though, what I've done so far is just making sure I'd type an extra "3" after each python-related command.
I'm still new to cygwin and python, any help would be very much appreciated, thanks!
I may be wrong here, but I did some digging, and it looks like they have been trying add cygwin support for psutil since 2010, see github page for psutil issue #82. Looks like there is no support for now.
I'm following a course called Automate the Boring Stuff, and I'm on the last part about pyautogui and pillow. I can import pyautogui and pillow successfully and I can use the keystroke functions of pyautogui but if I try to run a function in pyautogui that involves pillow it gives me this error. The function I'm trying to run is pyautogui.screenshot()
File "<input>", line 1, in <module>
File "C:\Users\offic\PycharmProjects\test\venv\Lib\site-packages\pyscreeze\__init__.py", line 134, in wrapper
raise PyScreezeException('The Pillow package is required to use this function.')
pyscreeze.PyScreezeException: The Pillow package is required to use this function.
and here is the code in pyscreeze that determines if pillow is there
try:
from PIL import Image
from PIL import ImageOps
from PIL import ImageDraw
if sys.platform == 'win32': # TODO - Pillow now supports ImageGrab on macOS.
from PIL import ImageGrab
_PILLOW_UNAVAILABLE = False
except ImportError:
# We ignore this because failures due to Pillow not being installed
# should only happen when the functions that specifically depend on
# Pillow are called. The main use case is when PyAutoGUI imports
# PyScreeze, but Pillow isn't installed because the user is running
# some platform/version of Python that Pillow doesn't support, then
# importing PyAutoGUI should not automatically fail because it
# imports PyScreeze.
# So we have a `pass` statement here since a failure to import
# Pillow shouldn't crash PyScreeze.
_PILLOW_UNAVAILABLE = True
def requiresPillow(wrappedFunction):
"""
A decorator that marks a function as requiring Pillow to be installed.
This raises PyScreezeException if Pillow wasn't imported.
"""
#functools.wraps(wrappedFunction)
def wrapper(*args, **kwargs):
if _PILLOW_UNAVAILABLE:
raise PyScreezeException('The Pillow package is required to use this function.')
return wrappedFunction(*args, **kwargs)
return wrapper
if I try to just type 'from PIL import Image' it gives this error
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "C:\Program Files\JetBrains\PyCharm Edu 2019.1\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "C:\Users\offic\PycharmProjects\test\venv\Lib\site-packages\PIL\Image.py", line 93, in <module>
from . import _imaging as core
ImportError: cannot import name '_imaging' from 'PIL' (C:\Users\offic\PycharmProjects\test\venv\Lib\site-packages\PIL\__init__.py)
and this is when I installed Pillow
C:\Users\offic>py -m pip install --user Pillow
Requirement already satisfied: Pillow in c:\users\offic\pycharmprojects\test\venv\lib\site-packages (7.1.1)
this is what pillow looks like in my package directory
and pyscreeze says it's supposedly satisfied with the install of Pillow
C:\Users\offic>py -m pip install --user pyscreeze
Requirement already satisfied: pyscreeze in c:\users\offic\pycharmprojects\test\venv\lib\site-packages (0.1.26)
Requirement already satisfied: Pillow>=5.2.0 in c:\users\offic\pycharmprojects\test\venv\lib\site-packages (from pyscreeze) (7.1.1)
I don't know what is going on because I've had almost no problems with installing packages before and it seems to be in the right location and up to date. Please help me!
Even I had the same error, here is what worked for me:
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade Pillow
I found this in the official documentation of Pillow package
I'm using windows and this method worked for me.
pip install --upgrade pip
pip install --upgrade Pillow
Despite the misleading contextual evidence, what you are looking for is the cv2 library, not PIL strictly.
So install cv2, e.g. using pip:
pip install opencv-python
Then import it within your Python script:
import cv2
Then run it.
I also had the same issue, I have the latest version of the python interpreter, the latest version of the pyscreeze, I read the docs, but nothing found, I google it, but hopelessly nothing,
But I was about losing hope when I found this, we can call the pyscreeze module instead of the pyautogui module,
import pyautogui
import pyscreeze
image = pyscreeze.screenshot('screenshot.png')
print(image.size)
Finding more at https://pypi.org/project/PyScreeze/
For my case, in pycharm,
move these two files:
PIL,
Pillow-9.4.0.dist-info,
from
C:\Users\xxxxxxxxxxxx\AppData\Local\Programs\Python\Python311\Lib\site-packages
to PyCharm project
C:\Users\xxxxxxxxxxxx\PycharmProjects\xxxxxxxxxxxx\venv\Lib\site-packages
enter image description here
It's a version issue, you can solve it by
uninstalling current Pillow version
and re-installing the proper version, e.g. 8.1.2
pip uninstall Pillow,
pip install Pillow==8.1.2
(call me "LEI, FENG")
When trying to run any Python script - Python2 or Python3 and install pip, I get an error:
Traceback (most recent call last):
File "inSp3ctor.py", line 22, in <module>
from colorama import Fore, Back, Style
ImportError: No module named colorama
If I try to sudo pip install colorama it tells me that the requirement is already satisfied:
asdw#sasxa:~/Desktop/inSp3ctor$ sudo pip install colorama
Requirement already satisfied: colorama in /usr/local/lib/python3.6/dist-packages (0.3.9)
I think the problem is occurring due to different versions of python on your machine and you might be making use of python3 , so try performing pip3 install your module name
and re open the idle or ide and run the code
while installing opencv in did that ln -s command and now numpy module is not working if i try to install numpy it shows this
$ pip install numpy
Requirement already satisfied: numpy in /Users/deepakpatel/miniconda3/lib/python3.6/site-packages (1.15.0)
but when i try to import that module in python programs its not working it shows this
import numpy
Traceback (most recent call last):
File "", line 1, in
ModuleNotFoundError: No module named 'numpy'
so i need some help with this guys
if you need more info just comment down below
I am using python 2.7.6 on Ubuntu 14.04 LTS. When I run this command:
sudo pip install pypdf2
The following message shows up:
Requirement already satisfied (use --upgrade to upgrade):
pypdf2 in /usr/local/lib/python2.7/dist-packages
Cleaning up...
This means that pypdf2 is already installed on my system but when I try to import pyPDF2, this message comes up:
>>> import pyPDF2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named pyPDF2
Capitalization counts. Try import PyPDF2 and see if that works.