macos

Detect key-presses with Python in macOS

Detect key-presses with Python in macOS Question: I wrote a macro that use key-presses to record. It is using the keyboard module that does not work on macOS. Code import time import keyboard import pyautogui while True: if keyboard.is_pressed(‘e’): #recording v = [0] z = True m = time.time() while z == True: if keyboard.is_pressed(‘space’): …

Total answers: 1

Do pyperclip3 or pasteboard support paste of PNG on macOS

Do pyperclip3 or pasteboard support paste of PNG on macOS Question: I am trying to figure out how to paste a PNG graphic from the clipboard into a Python script on macOS. I have looked into using the pyperclip, pyperclip3, and pasteboard modules. I cannot get any of these to work. I am able to …

Total answers: 1

Tensorflow Error on Macbook M1 Pro – NotFoundError: Graph execution error

Tensorflow Error on Macbook M1 Pro – NotFoundError: Graph execution error Question: I’ve installed Tensorflow on a Macbook Pro M1 Max Pro by first using Anaconda to install the dependencies: conda install -c apple tensorflow-deps Then after, I install the Tensorflow distribution that is specific for the M1 architecture and additionally a toolkit that works …

Total answers: 1

PyTorch memory leak reference cycle in for loop

PyTorch memory leak reference cycle in for loop Question: I am facing a memory leak when iteratively updating tensors in PyTorch on my Mac M1 GPU using the PyTorch mps interface. The following is a minimal reproducible example that replicates the behavior: import torch def leak_example(p1, device): t1 = torch.rand_like(p1, device = device) # torch.cat((torch.diff(ubar.detach(), …

Total answers: 1

Scheduling a Python script to run every 1 hr (details in description)

Scheduling a Python script to run every 1 hr (details in description) Question: My question is simple. I have a Python script that pulls data from an API that has a limit of only 150 requests per hour (here 150 dates of data). I have a total of 6 chunks (6 * 150) to pull. …

Total answers: 2

Cannot install Scrapy on macOS M1 13.0.1 – lxml installation error: '/usr/bin/clang' failed with exit code 1

Cannot install Scrapy on macOS M1 13.0.1 – lxml installation error: '/usr/bin/clang' failed with exit code 1 Question: I’m trying to install Scrapy in my Macbook M1 with macOS Ventura 13.0.1, but it is throwing an error while trying to install lxml. Installing collected packages: lxml, jmespath, itemadapter, idna, filelock, cssselect, charset-normalizer, cffi, certifi, attrs, …

Total answers: 2

Can't find jedi-language-server in command line in mac but can in Linux

Can't find jedi-language-server in command line in mac but can in Linux Question: Questions I install jedi-language-server as the README.md. but I can’t find jedi-language-server –help in My Mac(13 Ventura) system. But I can find this package in the pip list. ➜ ~ pip3 list | grep jedi jedi 0.18.2 jedi-language-server 0.40.0 PATH and others …

Total answers: 1

How to get `multiprocessing.queues.Queue.qsize()` on macOS?

How to get `multiprocessing.queues.Queue.qsize()` on macOS? Question: This is an old issue which suggested workaround does not work. Below is a complete example showing how the suggested approach fails. Uncomment L31 for error. import multiprocessing import os import time from multiprocessing import get_context from multiprocessing.queues import Queue class SharedCounter(object): def __init__(self, n=0): self.count = multiprocessing.Value(‘i’, …

Total answers: 1

pybind11 module dependencies macOS

pybind11 module import or link .so dependencies macOS Question: TLDR: How do I link a .so/import a dependency when importing my pybind11 module in python? I am attempting to build a pybind11 module that, in parts, depends on the C++ part of a different python library. On Linux, I can just link that library in …

Total answers: 1

How to compile Tkinter as an executable for MacOS?

How to compile Tkinter as an executable for MacOS? Question: I’m trying to compile a Tkinter app as an executable for MacOs. I tried to use py2app and pyinstaller. I almost succeed using py2app, but it returns the following error: Traceback The Info.plist file must have a PyRuntimeLocations array containing string values for preferred Python …

Total answers: 2