Installing pillow fails on Linux environment or Chrome OS. How do I fix this?
When I try to install pillow with pip3, it gives me the following error message.
failed building wheel for pillow
[omitted text]
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;file='/tmp/pip-install-092vzzoo/pillow/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-record-v4rw5g1c/install-record.txt --single-version-externally-managed --compile --user --prefix=" failed with error code 1 in /tmp/pip-install-092vzzoo/pillow/
do you know?
how many words do you know
See also questions close to this topic
-
Python File Tagging System does not retrieve nested dictionaries in dictionary
I am building a file tagging system using Python. The idea is simple. Given a directory of files (and files within subdirectories), I want to filter them out using a filter input and tag those files with a word or a phrase.
If I got the following contents in my current directory:
data/ budget.xls world_building_budget.txt a.txt b.exe hello_world.dat world_builder.spec
and I execute the following command in the shell:
py -3 tag_tool.py -filter=world -tag="World-Building Tool"
My output will be:
These files were tagged with "World-Building Tool": data/ world_building_budget.txt hello_world.dat world_builder.spec
My current output isn't exactly like this but basically, I am converting all files and files within subdirectories into a single dictionary like this:
def fs_tree_to_dict(path_): file_token = '' for root, dirs, files in os.walk(path_): tree = {d: fs_tree_to_dict(os.path.join(root, d)) for d in dirs} tree.update({f: file_token for f in files}) return tree
Right now, my dictionary looks like this:
key:''
.In the following function, I am turning the empty values
''
into empty lists (to hold my tags):def empty_str_to_list(d): for k,v in d.items(): if v == '': d[k] = [] elif isinstance(v, dict): empty_str_to_list(v)
When I run my entire code, this is my output:
hello_world.dat ['World-Building Tool'] world_builder.spec ['World-Building Tool']
But it does not see
data/world_building_budget.txt
. This is the full dictionary:{'data': {'world_building_budget.txt': []}, 'a.txt': [], 'hello_world.dat': [], 'b.exe': [], 'world_builder.spec': []}
This is my full code:
import os, argparse def fs_tree_to_dict(path_): file_token = '' for root, dirs, files in os.walk(path_): tree = {d: fs_tree_to_dict(os.path.join(root, d)) for d in dirs} tree.update({f: file_token for f in files}) return tree def empty_str_to_list(d): for k, v in d.items(): if v == '': d[k] = [] elif isinstance(v, dict): empty_str_to_list(v) parser = argparse.ArgumentParser(description="Just an example", formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument("--filter", action="store", help="keyword to filter files") parser.add_argument("--tag", action="store", help="a tag phrase to attach to a file") parser.add_argument("--get_tagged", action="store", help="retrieve files matching an existing tag") args = parser.parse_args() filter = args.filter tag = args.tag get_tagged = args.get_tagged current_dir = os.getcwd() files_dict = fs_tree_to_dict(current_dir) empty_str_to_list(files_dict) for k, v in files_dict.items(): if filter in k: if v == []: v.append(tag) print(k, v) elif isinstance(v, dict): empty_str_to_list(v) if get_tagged in v: print(k, v)
-
Actaully i am working on a project and in it, it is showing no module name pip_internal plz help me for the same. I am using pycharm(conda interpreter
File "C:\Users\pjain\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Users\pjain\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code exec(code, run_globals) File "C:\Users\pjain\AppData\Local\Programs\Python\Python310\Scripts\pip.exe\__main__.py", line 4, in <module> File "C:\Users\pjain\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\__init__.py", line 4, in <module> from pip_internal.utils import _log
I am using pycharm with conda interpreter.
-
Looping the function if the input is not string
I'm new to python (first of all) I have a homework to do a function about checking if an item exists in a dictionary or not.
inventory = {"apple" : 50, "orange" : 50, "pineapple" : 70, "strawberry" : 30} def check_item(): x = input("Enter the fruit's name: ") if not x.isalpha(): print("Error! You need to type the name of the fruit") elif x in inventory: print("Fruit found:", x) print("Inventory available:", inventory[x],"KG") else: print("Fruit not found") check_item()
I want the function to loop again only if the input written is not string. I've tried to type return Under print("Error! You need to type the name of the fruit") but didn't work. Help
-
Linux on Lightsail instance is asking for a password and it's not working
I'm trying to restart
mariaDB
on Ubuntu but it's not letting me.I enter:
systemctl restart mariadb
and get:
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units === Authentication is required to restart 'mariadb.service'. Authenticating as: Ubuntu (ubuntu) Password: polkit-agent-helper-1: pam_authenticate failed: Authentication failure ==== AUTHENTICATION FAILED ===
I have the same password for all functions so I do not understand why it is not working. What can I do?
-
How to tag and store files, by metadata, in Python?
I want to build a manual file tagging system like this. Given that a folder contains these files:
data/ budget.xls world_building_budget.txt a.txt b.exe hello_world.dat world_builder.spec
I want to write a tagging system where executing
py -3 tag_tool.py -filter=world -tag="World-Building Tool"
will output
These files were tagged with "World-Building Tool": data/world_building_budget.txt hello_world.dat world_builder.spec
Another example. If I execute:
py -3 tag_tool.py -filter="\.txt" -add_tag="Human Readable"
It will output
These files were tagged with "Human Readable": data/world_building_budget.txt a.txt
I am not asking "Do my homework for me". I want to know what approach I can take to build something this? What data structure should I use? How should I tag contents in a directory?
-
PIL ("PIllow") in python 3.10.4 from windows store throws ModuleNotFoundError
In Python 3.10.4, when I try to run any code that has the following line of code in it
from PIL import Image, ImageTk
it returns:
Traceback (most recent call last): File "<stdin>", line 1, in <module> ModuleNotFoundError: No module named 'PIL'
I've tried it on Python 3.9.7 and it worked fine.
-
When I close the Video Chat I recive message that Exception ignored in: <function PhotoImage.__del__ at 0x000002C3C2EB1A60>. Why I get this Error?
I'm trying to build video chat by using cv2 and Tkinter. There is Server And client and with thread they send to each other the frames from their cameras def recv_video(self):
data = b"" payload_size = struct.calcsize("Q") # Q: unsigned long long integer(8 bytes) while self.IsRevcVideo: try: while len(data) < payload_size: packet = self.client_socket_VID.recv(4 * 1024) # 4K, range(1024 byte to 64KB) if not packet: break data += packet # append the data packet got from server into data variable packed_msg_size = data[ :payload_size] # will find the packed message size i.e. 8 byte, we packed on server side. data = data[payload_size:] # Actual frame data msg_size = struct.unpack("Q", packed_msg_size)[0] # message size # print(msg_size) while len(data) < msg_size: data += self.client_socket_VID.recv(4 * 1024) # will receive all frame data from client socket frame_data = data[:msg_size] # recover actual frame data data = data[msg_size:] frame = pickle.loads(frame_data) # de-serialize bytes into actual frame type self.partnerphoto = ImageTk.PhotoImage(image=Image.fromarray(frame)) self.canvasPartnerFrame.create_image(0, 0, image=self.partnerphoto, anchor='nw') self.partner_cnt += 1 print("partnerframe update", self.partner_cnt) except: break
when the server side close the program he call the method with self.window.protocol("WM_DELETE_WINDOW", self.on_closing)
def on_closing(self): print("\nClosing Program") #end loops self.IsRevcVideo = False self.IsUpdateVideo = False self.IsRevcVoice = False self.IsSendVoice = False self.cam.release() self.client_socket_VID.close() self.send_client_socket_VOI.close() self.receive_client_socket_VOI.close() self.window.destroy() print("VIDEO CHAT CLOSED")
and when I click on the X button I get this Error:
Exception ignored in: <function PhotoImage.__del__ at 0x000002C3C2EB1A60> Traceback (most recent call last): File "C:\Users\User\PycharmProjects\LoLevadProject\venv\lib\site-packages\PIL\ImageTk.py", line 145, in __del__ name = self.__photo.name AttributeError: 'PhotoImage' object has no attribute '_PhotoImage__photo'
Why the Exception ignored? How to fix it?
-
keyboard event has key="Process" on Chromebook
I'm working on a text editor and I'm facing a weird behavior on Chromebooks. When they press a composition key (like ` or ^), I receive a keyDown event with key="Process". This is documented nowhere. It doesn't follow the specs, and I couldn't find anything about it on the internet.
The main issue here is that the composition doesn't start after this event, and so the editor prints both the composition key and the letter. Like
^a
instead ofâ
. I tested on 2 Chromebooks and got the same result.What is interesting though is that, if I press the key twice, I correctly get a
Dead
key event, and the composition starts normally.Does anyone know anything about the meaning of this
Process
key? -
Why isn't my image loading on pygame on chromebook?
I'm coding in python with pygame, but my images won't open. When I try to load an image, this error message pops up:
Exception has occurred: error Couldn't open player0.png
. I have looked at other people's solutions, but none of them worked. I have tried converting the image into .bmp and .jpg, but it made no difference and gave me the same error message. I have also tried to put it into a separate folder and do this:img = pygame.image.load('assets/player0.png')
, but it made no difference. This is my code currently:import pygame,sys from pygame.locals import * pygame.init() pygame.display.init() screen = pygame.display.set_mode((800,600)) player = pygame.image.load('player0.png') while True: screen.fill((255,255,255)) screen.blit(player, (100,100)) for event in pygame.event.get(): if event.type == QUIT: pygame.quit() sys.exit() pygame.display.update()
-
ChromeOS startActivity does not work if I close app (X top right) and get a notification
I have a ChromeOS 100 Acer Chromebook 314. I open the app, I am logged in, and after that I will close it from the top-right corner. Then I receive a notification and I run this code:
try { val intentActivity = Intent(context, IncomingCallActivity::class.java) intentActivity.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) context.startActivity(intentActivity) } catch (e: Exception) { FL.e(TAG, "makeCall()::Failed -> cannot start activity: ${e.message}") }
This does not fail, but does not open the activity neither.
I have also tried:
PendingIntent.getActivity(context, 12346, intentActivity, PendingIntent.FLAG_IMMUTABLE).send()
But same issue. This works fine on phones. BUT on phones I am running this from the ConnectionService.onShowIncomingCall. I cannot use that because there is no ConnectionService in the chromeOS api. Any idea I can make my activity appear properly always?