macos

How not to mess terminal up after sys.stdin.read() and subprocess invoking vim?

How not to mess terminal up after sys.stdin.read() and subprocess invoking vim? Question: I want to create interactive mode code like git rebase -i HEAD~6 but for PIPE editing, stdin redirection. another example is vipe of moreutils. To do that, I learn this code below. # Source: https://stackoverflow.com/a/39989442/20307768 import sys, tempfile, os from subprocess import …

Total answers: 1

How to use variable volume control for mac via python?

How to use variable volume control for mac via python? Question: I found this code in python to control mac volume: osascript.osascript("set volume output volume 35") I want to use a variable to control this volume instead like: volumes = [35, 35, 30, 35, 45, 45, 45, 45, 45, 40, 45, 45, 45, 45, 55, …

Total answers: 2

How to find MacOS 'Utilities' folder contents with Python

How to find MacOS 'Utilities' folder contents with Python Question: When calling : Path(‘/Applications/Utilities’).iterdir() The returned result is only ‘.localized’ but when I look in the Utilities folder with finder there are many apps – Disk Utility, Airport Utility, etc. I hav also tried .listdir() with the OS module and same result. Bigger code sample …

Total answers: 1

Tensorflow M2 Pro Failure

Tensorflow M2 Pro Failure Question: When I run the following test script for tensorflow import tensorflow as tf cifar = tf.keras.datasets.cifar100 (x_train, y_train), (x_test, y_test) = cifar.load_data() model = tf.keras.applications.ResNet50( include_top=True, weights=None, input_shape=(32, 32, 3), classes=100,) loss_fn = tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True) model.compile(optimizer="adam", loss=loss_fn, metrics=["accuracy"]) model.fit(x_train, y_train, epochs=5, batch_size=4) I obtain the following terminal output: Metal device set …

Total answers: 1

AttributeError: 'cv2.VideoCapture' object has no attribute 'isOpend'

AttributeError: 'cv2.VideoCapture' object has no attribute 'isOpend' Question: I have a problem using OpenCV with VS Code I checked version of OpenCV and Python, but I don’t know what’s wrong. opencv version is 4.7.0 vscode interpreter is python 3.9.13(‘base’) /opt/anaconda3/bin/python here is condalist opencv-contrib-python 4.7.0.72 pypi_0 pypi opencv-python 4.7.0.72 pypi_0 pypi this is my code …

Total answers: 1

python access /Library on macos

python access /Library on macos Question: I am trying to write an install file to the /Library folder if the user doesn’t have it. I can run the code in "sudo python …" and it works. However using pyinstaller and creating a packaged app gives me an Error 13 permission denied. [Errno 13] Permission denied: …

Total answers: 1

Cross platform time calculation

Cross platform time calculation Question: try: Start = time.clock() # best method to measure time on windows except: Start = time.time() # cross platform time main() # code to measure time of try: End = time.clock() # for windows except: End = time.time() # cross platform I am attempting to calculate the time it takes …

Total answers: 1

Anaconda Navigator not opening on M2 MacBook Air running MacOS Ventura

Anaconda Navigator not opening on M2 MacBook Air running MacOS Ventura Question: I just downloaded anaconda on my M2 MacBook Air running MacOS Ventura (version 13.2.1). The download process went smoothly and I was able to locate Anaconda Navigator. But when I try opening it, it just won’t open without even showing any error message. …

Total answers: 1