Interfacing thorlabs equipment with pylablib - python

I'm trying to use pylablib to access a thorlabs motor using python3.6 but I can't open the device
the documentation seems simple, but I'm new to python and can't work out what I'm doing wrong.
https://pylablib.readthedocs.io/en/latest/.apidoc/pylablib.aux_libs.devices.html#pylablib.aux_libs.devices.Thorlabs.KDC101
import pylablib as pll
from pylablib.aux_libs.devices import Thorlabs
with Thorlabs.KDC101("27254309") as stage:
stage.get_status_n()
I get the error
File "...\backend.py" line 674, in init
raise self.BackendOpenError(e)
pylablib.core.devio.backend.BackendOpenError:
Device Not Opened
can anyone please suggest to me how I might be referring to the motor wrong or what I might be able to try?
Thanks.

I know this probably isn't gonna help but I had a similar problem and then after five minutes realized the motors weren't turned on. Felt pretty stupid.
Edit: another issue I had was that when I installed pylablib, I simply used:
pip install pylablib
Instead, you need to do this:
pip install pylablib[devio,gui]

Related

Keeps saying that Python is not found and that I need to install it on Microsoft even though I got the extensions?

I am very much a new person to coding and I was primarily trying to do something for some browser game I play. This message is what I am most concerned of: "Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases." I've looked at countless videos and articles but cannot find anything that is of use for me. I don't know if this has been an issue for anyone else or has been asked of and I use Python. Could someone please help me? I also use Windows 10 with the newest version possible (3.10.6).
https://i.stack.imgur.com/Soiiw.png
Can you please reinstall the python
when installing make sure to check add python 3.10.6(your version) as Path
and in your code you hace to use this code to import emoji library also
pip install emoji
hope it helps:)
For me, turning off Python under "Apps > App Execution Aliases" in Windows 11 settings fixed it.
Fix Python for Stable Diffusion on Windows 11

Python can't find automlconfig and automlrun

I'm working on azure from past few months, and everything was working fine, and now I'm having issues, I cant import automlconfig and automlrun from azureml.train.automl. I have tried all possible solutions, even azure jupyter-vm which by default must have all these libraries but no success yet. I cant find this issue on there forums, any help or advice would be great.
error text:- (cannot import name 'AutoMLConfig',cannot import name 'AutoMLrun')
Could you please try following steps to see if it helps or not?
Completely uninstalled conda and reinstalled
Built the azure_automl env using azure_automl.cmd
Got from azureml.train.automl import AutoMLConfig to work.
Please let me know if you still have problem.
Regards,
Yutong

Import serial to Python

I do have a problem which many people faced already, but after searching through different solutions for hours, I still haven't solved my problem.
For a project, I need Phyton to read my Data from my arduino-uno. Therefore I need the import serial (or import pyserial, I tried both) this doesn't work. I tried installing the library (not really sure where to store it than) but that didn't help either. I also tried using "pip install pyserial" in the console, but that didn't work as well.
Whatever i do i allwas get this error:
pip install pyserial
File "", line 1
pip install pyserial
^
SyntaxError: invalid syntax
I reinstalled Python now as 2.7 and deleted everything Python related. But when i put in pip install pyserial i still geht the same Error
Could someone please help me with this?
Thanks
If you installed pyserial as you stated in the comments using the PyPI command pip install pyserial then you should use
import serial
and not import pyserial as it is shown in the documentation here
If this doesn't work, either there was a problem when installing the library, or you may not be using the same Python environment as the one you think you are (as you did not give details on how you run the script it's hard to tell).
Problem Solved!
Seems like my computer doesn't like python.
Thanks for your help

"SignatureError: Failed to verify signature" - Okta, pySAML2

For three days, I have been pulling my hair out trying to wrap my head around Okta & SAML.
On my local machine (OSX Mavericks), I am able to successfully follow the steps listed here: http://developer.okta.com/docs/guides/pysaml2
Things work.
But moving everything over to our production server, which is a CentOS box, running nearly identical code, I am faced with this "SignatureError: Failed to verify signature" error.
Traceback (most recent call last):
auth_response = saml_client.parse_authn_request_response(SAMLResponse, entity.BINDING_HTTP_POST)
File \"/usr/local/lib/python2.7.11/lib/python2.7/site-packages/saml2/client_base.py\", line 599, in parse_authn_request_response binding, **kwargs)
response = response.loads(xmlstr, False, origxml=origxml)
File \"/usr/local/lib/python2.7.11/lib/python2.7/site-packages/saml2/response.py\", line 510, in loads self._loads(xmldata, decode, origxml)
File \"/usr/local/lib/python2.7.11/lib/python2.7/site-packages/saml2/response.py\", line 335, in _loads **args)
File \"/usr/local/lib/python2.7.11/lib/python2.7/site-packages/saml2/sigver.py\", line 1756, in correctly_signed_response
class_name(response), origdoc)
File \"/usr/local/lib/python2.7.11/lib/python2.7/site-packages/saml2/sigver.py\", line 1571, in _check_signature
raise SignatureError(\"Failed to verify signature\")
SignatureError: Failed to verify signature
I have scoured the internet looking for a way to troubleshoot this error. I am new to SAML and Okta.
My assumption is that this has something to do with xmlsec1 acting differently on our production machine. But the versions are identical. There are many dependencies so I'm not sure where the problem might be.
Has anyone ran into this error? Any thoughts on what I might be able to try?
I know this is a little late, but in case someone else runs into this:
pysaml2 provides a lot of logging using python's built in logging, I defined a handler for saml2.sigver and that gave a lot of info. In those logs I found this:
Error: unable to load xmlsec-openssl library. Make sure that you have
this it installed, check shared libraries path (LD_LIBRARY_PATH)
envornment variable or use "--crypto" option to specify different
crypto engine.
Turns out I needed to install xmlsec1-openssl.
Hope this helps someone in the future.
Dealing with xmlsec1 can be extremely frustrating!
The main thing that I suggest doing is enabling debugging in PySAML2, and/or setting the PYSAML2_KEEP_XMLSEC_TMP environment variable, and/or manually enable this code path in sigver.py - the general idea is to get a look at xmlsec1 command that PySAML2 is calling and have PySAML2 leave the temporary files around so that you can test the commands yourself.
As I recall, most of the issues that I've run into in the past involved PySAML2 not finding the xmlsec1 binary. The get_xmlsec_binary() function in sigver.py is responsible for finding the xmlsec1 binary. I suggest that you take a look at the code in get_xmlsec_binary() and make sure that it is looking in the right places on your system.
Depending on the operational system you will also need to install additional libraries.
In my case, I got the issue on a CentOS server, so I needed to install more 2 dependencies in addition to xmlsec1:
yum install libffi-devel xmlsec1 xmlsec1-openssl
This solved my problem.
You should also have a look on Okta's documentation. They have a guide on how to use PySAML2 to add support for Okta (via SAML) to applications written in Python.
https://developer.okta.com/code/python/pysaml2/

Using Pexpect with Python 3

After hours of research I have broken down to posting. I am trying to use the Pexpect module with python 3, which I am led to believe is possible from the document page which does say it will run with python 3.2.
Things I have tried: I have tried many different ways of installing including downloading the source and running the command sudo python3 setup.py install. I have also tried installing it with pip and *easy_install* which is what the documentation suggest. It seems that everything goes off with out a hitch until I attempt to import the module in the pyshell. When I type import pexpect I get the error:
class spawn(object):
File "/usr/local/lib/python3.2/dist-packages/pexpect/init.py", line 286, in spawn
write_to_stdout = sys.stdout.buffer.write
AttributeError: 'PseudoFile' object has no attribute 'buffer'
I have also tried googleing the error with no luck. And I have tried using python 2.7 and it works fine. I have tried on multiple debian based operating systems: Ubuntu 12.04 and Kali with the same results.
I feel like there is something obvious I am missing, but I just don't see it. Any points in the right direction Or helping me understand the error message would be much appreciated!
There was a bug in Pexpect 3.0 which stopped it working if sys.stdout was replaced before it was imported. It looks like IDLE replaces stdout, so as you've found, it doesn't work in IDLE & Python 3.
The bug has now been fixed. I'll try to get a new version of Pexpect out in the next few days, and then you'll be able to use it from IDLE.

Categories

Resources