I am trying to get PyVisa working on my mac. I have installed it and NI libraries but when I try to run the following simple python file from terminal in VS code:
import sys
import pyvisa as visa
rm = visa.ResourceManager()
rm.list_resources()
inst = rm.open_resources('GPIB::10::INSTR') #Instrument GPIB Addr = 10
print (inst.query("*IDN?"))
By running 'python3 temp.py' I get the following error message:
Error Domain=KMErrorDomain Code=71 "Insufficient permissions for action: Unable to load 'com.highpoint-tech.kext.HighPointRR' in unprivileged request." UserInfo={NSLocalizedDescription=Insufficient permissions for action: Unable to load 'com.highpoint-tech.kext.HighPointRR' in unprivileged request.}
zsh: abort python3 temp.py
Make sure com.ni.driver.NiViPciK extension is installed and loaded. For this, go to About This Mac -> System Report -> Extensions (in Software section) and find NiViPciK. It will likely say "Loaded: No". You need to manually allow National Instruments extensions.
Boot into recovery mode by holding Cmd-R while powering up.
Open Terminal from Tools menu.
Execute: spctl kext-consent add SKTKK2QZ74
Reboot
This did the trick for me:
I have been using NI IVI backend, but lately gave a spin to open source PyVISA-py backend instead and it has worked great for our automation purposes both on OSX and Linux.
I changed
rm = visa.ResourceManager() to rm = visa.ResourceManager('#py').
Some minor modifications may be needed (I had to remove instrument.clear() calls for some reason).
Related
im on macbook old version El Capitan 10.11.6 and my python script is 147bytes just for auto shutdown program but when i try to boundle it pyinstaller filename.py it done almost everything and end up with (codesign failure). do someone know how to solve this?
Try the following command in your terminal, type: sudo codesign -f -s followed by your script name test.py Make sure you are in your script file directory by using cd path to your file folder.
After that, you can run pyinstaller test.py However, I am using macOS Monterey Version 12.6 and am not sure if it will work on your current version. In fact, I don't even know how that command makes it work, but it works for me. If your app is a windowed app, such as the Tkinter app, your system may prevent it from opening; in that case, use the following command to disable the security system sudo spctl --master-disable . then you will see a new option available in your macOS Settings under Security; down there it says Allow app from: App Store, App Store and identified developer; and at last, you will see a new option "Anywhere" which wasn't there before; check that, and your app will work perfectly. hope helped
I am a freelancer and my clients need screenshots of all the work I did. So I made a python script which takes screenshots every 7 minutes and this code gets executed automatically when system starts. It worked perfectly in Ubuntu. This is the code.
Now I switched to Fedora34. I have modified my script litte bit which captures screenshots and saves in folders according to date rather than putting all screenshots in one directory. This is my script for Fedora
#!/usr/bin/env python
import pyscreenshot
import time
from datetime import datetime
import os
from pathlib import Path
while True:
# Get Current time
now = datetime.now()
# setting current datetime as image_filename
image_filename = now.strftime("%b-%d-%Y|%H:%M:%S")
# Getting month, year and date
today_month_year = now.strftime("%b-%Y")
today_date = now.strftime("%d")
new_directory = os.path.join(r"ss/",
str(today_month_year),
str(today_date))
# Create folders safely
Path(new_directory).mkdir(parents=True, exist_ok=True)
# To capture the screen
image = pyscreenshot.grab()
# To save the screenshot
image.save(new_directory + "/" + str(image_filename) + ".png")
# Each screenshot Every 7 minutes
time.sleep(420)
And fedora does not have Startup Applications app and gnome-tweaks > Startup Applications does not support custom scripts. So I searched at many sites and came to conclusion that I can create a service file. And I created a service file to start my script at startup with following code:
File: /etc/systemd/system/screenshots.service
[Service]
WorkingDirectory=/home/<uname>/path
ExecStart=/bin/sh -c 'cd /home/<uname>/path/ && source env/bin/activate && ./auto-ss.py'
Now when I run sudo systemctl start screenshots, it does not throw any error but running sudo systemctl status screenshots throws following error:
pyscreenshot.err.FailedBackendError: All backends failed!
According to this answer
PyScreenshot is for taking screenshots of desktop applications. Since your application is running on a server, there's nothing to take a screenshot of. If you intended to take a screenshot of the user's browser, you would use frontend tooling, which runs in the browser, not a server-side tool.
If this is the problem, how can I run my python app as frontend. And if its some other problem, how can I overcome it?
Can anyone help me. I am stuck on this since very long :( . Well, thanks in advance :)
If it works on Ubuntu and doesn't work for Fedora, the sure way to fix it is to mimic Ubuntu on Fedora (i.e. via desktop environments). Ubuntu uses gnome. So, your best bet is to use gnome on Fedora too.
Please have a look at these links:
What is the recommended way to install Gnome on Fedora 30 Server?
Install Gnome 3 in Fedora 22 KDE Spin
Fedora 32: Gnome Desktop
Environment
Python 3.7
Mac OS Catalina 10.15
Problem
I am developing a software with Python for Mac OS X. I will compile it with Nuitka.
When I run my compiled program, it doesn't work.
When I was searching for solutions on Google, some people speak about checking the log system of the Mac OS.
So I found it here: Finder > Applications > Utilities > Console
The console is full of logs system messages. My problem is I don't know how can I filter all these logs to show only the ones connected to the execution of my software.
I use the logging module to create a log file for my python script but this log file is not produced. I guess program bug before it can create a log file.
Is there another way to check the logs?
Edit:
To compile my code, I execute this Nuitka command:
sudo python3 -m nuitka --standalone --plugin-enable=gevent --plugin-enable=qt-plugins --plugin-enable=pylint-warnings --show-progress --show-scons --follow-imports --recurse-all --windows-icon=phonebot_icon.icns MyApp.py
The result is 2 folders:
MyApp.build
MyApp.dist
MyApp.dist contains the executable file "MyApp" and some .so files.
From Finder, I can't browse MyApp.dist as it is seen as unknown file. So the only way to run the executable file is from terminal. I do:
sudo open MyApp
A new terminal window open and I get this output:
Last login: Thu Sep 3 12:46:32 on ttys001
/Users/gauthierbtz/Dropbox/cff/Python/MyApp/MyApp.dist/MyApp ; exit;
(base) gauthierbtz#MacBook-de-Gauthier ~ % /Users/gauthierbtz/Dropbox/cff/Python/MyApp/MyApp.dist/MyApp ; exit;
Password:
LSOpenURLsWithRole() failed for the application /Applications/MyApp.app with error -10810.
It looks like it try to go to Applications folder to open the MyApp.app which doesn't exist.
I try to run in the python shell some commands by using pyvisa. So I do the following as they show here, but when I execute rm = visa.ResourceManager() and press Enter, it crashes, and I get the Abort trap: 6 respond. Does anyone know what is wrong? My Python version is 3.6.3, and I am using the macOS Mojave.
import visa
rm = visa.ResourceManager()
Just ran into the same problem last week and was finally able to fix this issue on my mac.
Went on the NI forum and found the solution. They suggested rebooting your machine, go on System Preferences > Security and Privacy and allowing NI software to run on your machine. Link to a more details below, hope this helps.
https://forums.ni.com/t5/Instrument-Control-GPIB-Serial/Abort-problem-after-installing-NI-VISA-18-0-0-and-PyVisa-on-Mac/m-p/3819283/highlight/true#M77872
Once I navigate to a certain directory that has a .run file in it, how do I execute that file using mac Terminal?
I have change the chmod 777 for fileName.run file and run it
$ chmod 777 file-name.run
$ ./file-name.run
but it does not work for me. any idea ?
it give me the following error.
$ ./ppasmeta-9.4.1.3-linux-x64.run: cannot execute binary file
Its postgres plus advanced server for linux I want to install on mac os-x .
As suggested by Muhammad Iqbal, you won't be able to run a Linux-specific binary/executable on Mac OS X without some modifications. It's like attempting to run an .exe on Linux - without wine. While Linux and OS X are similar, they are not that compatible. If you can get your desired program in the form of a .deb, that may work. If not, I would suggest either dual-booting your Mac with a small Linux distro (ie. DSL) or picking up a virtual machine. I've dual-booted before - it's a decent option for this situation if you have enough hard drive space. If another solution shows up, I'll be sure to let you know through this channel.
I am not sure what you are asking here but try this
./run
As I said in the comments, I don't think that Postgres Advanced Server is available for OSX. If Postgres 9.5.3 is suitable for your purposes, you could install homebrew and use it to install Postgres 9.5.3 with:
brew install postgresql
You can download the one-liner to install homebrew from here.