Issues getting labscript to run on new computer

138 views
Skip to first unread message

Andrew Blackney

unread,
Apr 8, 2021, 2:25:17 PM4/8/21
to the labscript suite
I have a new computer with anaconda python installed and Labscript installed via conda as prescribed in the online docs (virtual environment, add labscript channel, conda install, get apps). I then had an issue with the anaconda tools not being on the virtual environment but I solved that issue via conda install and the enviorment seems to be working correctly. the issue I am having now is:

____________________________________________________________

  File "C:\...\Conn_table.py", line 72, in <module>

stop(t)

File "c:\...\labscript.py", line 2460, in stop

generate_code()

File "c:\...\labscript.py", line 2303, in generate_code

save_labscripts(hdf5_file)

File "c:\...\labscript.py", line 2188, in save_labscripts

prefix = os.path.dirname(labscriptlib.__file__)

File "c:\...\ntpath.py", line 223, in dirname

return split(p)[0]

File "c:\...\ntpath.py", line 185, in split

p = os.fspath(p)

TypeError: expected str, bytes or os.PathLike object, not NoneType

Compilation aborted.

____________________________________________________________

the connection table I have written is below:

from labscript import *

from labscript import start, stop, add_time_marker, AnalogOut, DigitalOut

from labscript_devices.PineBlaster import PineBlaster

from labscript_devices.NI_DAQmx.models.NI_PCIe_6363 import NI_PCIe_6363

from labscript_devices.NI_DAQmx.models.NI_PXIe_4322 import NI_PXIe_4322


# Use a virtual, or 'dummy', device for the psuedoclock

PineBlaster(name ='pulser', usbport = 'COM6')

NI_PCIe_6363(name ='ni_card_0', parent_device = pulser.clockline , clock_terminal = '/PXI1Slot18/PFI0' , MAX_name = 'PXI1Slot18' , acquisition_rate = 100e3)


NI_PXIe_4322(name ='ni_card_1', parent_device = pulser.clockline , clock_terminal = '/PXI1Slot18/PFI0' , MAX_name = 'PXI1Slot5')

# Create outputs

AnalogOut(name='analog_out', parent_device = ni_card_0, connection='ao0')

DigitalOut(name='digital_out', parent_device = ni_card_0, connection='port0/line0')

AnalogOut(name='analog_out_2', parent_device=ni_card_0, connection='ao1')

DigitalOut(name='digital_out_2', parent_device=ni_card_0, connection='port0/line1')


AnalogOut(name='analog_out_3', parent_device=ni_card_1, connection='ao0')

AnalogOut(name='analog_out_4', parent_device=ni_card_1, connection='ao1')



# if __name__ == '__main__':

    # Begin issuing labscript primitives

    # start() elicits the commencement of the shot

start()

t = 0.0

add_time_marker(t, "Start", verbose=True)

# Wait for 1 second with all devices in their default state

t += 1.0

analog_out.constant(t,3.0)

# Change the state of digital outputs, and denote this using a time marker

add_time_marker(t, "Toggle digital_out (high)", verbose=True)

digital_out.go_high(t)

digital_out_2.go_high(t)

# Wait for 1.0 seconds

t += 1.0

# Change the state of digital_out_2

add_time_marker(t, "Toggle digital_out (low)", verbose=True)

analog_out.sine_ramp(t, duration=1.0, initial= -1.0, final=-3.0, samplerate=10.0)

digital_out_2.go_low(t)

# Wait for 1.0 seconds

t += 1.0

# Ramp/Sine_Ramp analog outputs

add_time_marker(t, "strart Analog Ramps", verbose=True)

analog_out.constant(t,-3.0)

analog_out_2.constant(t,0.5)

t += 5.0

analog_out.constant(t,0.0)

analog_out_2.constant(t,1.0)

digital_out_2.go_high(t)

# Wait for 5.0 seconds

t += 5.0

add_time_marker(t, "digital low", verbose=True)

analog_out.constant(t,5.0)

digital_out_2.go_low(t)

t += 0.5

# Stop the experiment shot with stop()

stop(t)

____________________________________________________________

any help would be appreciated.


dihm....@gmail.com

unread,
Apr 8, 2021, 3:56:32 PM4/8/21
to the labscript suite
Andrew,

It would appear that you have found a way to compile your connectiontable in such that it cannot find the associated hdf5 to store the result in. Can you provide a little more detail on what you have done? In particular, how are you compiling this shot (via runmanager, the runmanager API, BLACS somehow)? In your new installation, have you checked settings in the experiment ini file? It is possible labscript is looking for the connectiontable.h5 file in a new folder than where you had originally kept it and that file will tell you where it needs to be. Assuming this is a from scratch installation, the method to get up and running is to use runmanager to compile the connectiontable once, then copy the .py and .h5 files to the necessary places as specified in the ini file.

Finally, I don't think it is strictly detrimental, but your connectiontable shouldn't have any actual commands in it (ie between start() and stop() ), just the definitions of devices that come before start(). 

Let me know if any of that helps (or at least changes the error).
-David

Zak V

unread,
Apr 8, 2021, 4:08:30 PM4/8/21
to the labscript suite
Hi Andrew, David,

It looks to me like something strange might be happening when labscript tries to import your labscriptlib module (here) such that labscript can import your labscript lib but then can't find the path to it. In addition to what David suggested, could you try running the following lines in a python interpreter?

import os
import labscriptlib
prefix = os.path.dirname(labscriptlib.__file__)

Also, if you don't mind could you share what you have set for the labscriptlib path in your labconfig? And just to check, have you restarted whichever labscript program created that error since fixing your environment?

Cheers,
Zak

Chris Billington

unread,
Apr 8, 2021, 7:13:03 PM4/8/21
to labscri...@googlegroups.com
Hi Andrew and others,

I think Zak is on the right track. More specifically, this is what would happen if the labscriptlib directory did not contain an __init__.py file.

The default labscriptlib folder created at install time does contain an __init__.py, but perhaps you deleted it, or changed the config setting to use a different directory as your labscriptlib, which does not contain an __init__.py?

In older versions of Python, you couldn't import a directory that did not contain an __init__.py, but now you can (in the case of a "namespace package"). So we should modify this part of labscript to instead inspect labscriptlib.__path__[0], which should always work.

If indeed this is the problem, Andrew, you might try replacing:

os.path.dirname(labscriptlib.__file__)

on the line that is crashing with:

labscriptlib.__path__[0]

Cheers,

Chris

--
You received this message because you are subscribed to the Google Groups "the labscript suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to labscriptsuit...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/labscriptsuite/e42deb70-28f8-41bf-89c0-247d17ad4d9en%40googlegroups.com.

Andrew Blackney

unread,
Apr 9, 2021, 12:15:22 PM4/9/21
to the labscript suite
Hello all,
First off thank you for the help! ok let me try to answer all the questions.
David - I am currently compiling this connectiontable via the runmanager gui.  I have not looked into the ini file. it may make sense that connectiontable.h5 file isn't in the right place since this installation is not in the default C:program files area.

Zak - running the code you suggested outputs the following :
--------------------------------------------------------------------------
TypeError Traceback (most recent call last) <ipython-input-2-900297abc460> in <module> 
1 import os 
2 import labscriptlib
  ----> 3 prefix = os.path.dirname(labscriptlib.__file__) 
C:\Apps\Anaconda3\envs\labscript\lib\ntpath.py in dirname(p) 
221 def dirname(p): 
222 """Returns the directory component of a pathname""" --> 
223 return split(p)[0] 
224 
225 # Is a path a symbolic link?
  C:\Apps\Anaconda3\envs\labscript\lib\ntpath.py in split(p) 
183 Return tuple (head, tail) where tail is everything after the final slash. 
184 Either part may be empty.""" 
--> 185 p = os.fspath(p) 
186 seps = _get_bothseps(p) 
187 d, p = splitdrive(p) 
TypeError: expected str, bytes or os.PathLike object, not NoneType

I believe the labconfig file you are asking about is the.ini file in the USERNAMe\labscript-suite\labconfig? If this is the file you are requesting the labconfig path to labscriptlib - is labscriptlib = %(userlib)s\labscriptlib\%(apparatus_name)s

Chris - I think you are probably right I do not have an init.py file in my labscriptlib folder I think it did get deleted/moved. how would I go about re-creating/restoring that file? if this init file doesn't work then I will give the other solution an try.

thanks again all of you for you very timely responses.   
Message has been deleted

Andrew Blackney

unread,
Apr 9, 2021, 3:31:18 PM4/9/21
to the labscript suite
another interesting error fun enough now I have an issue to work through this time with blacs :

Traceback (most recent call last):
  File "c:\apps\anaconda3\envs\labscript\lib\site-packages\zprocess\process_tree.py", line 1408, in subprocess
    msg = from_child.get(startup_timeout, interruptor=startup_interruptor)
  File "c:\apps\anaconda3\envs\labscript\lib\site-packages\zprocess\process_tree.py", line 511, in get
    raise TimeoutError('get() timed out')
zprocess.utils.TimeoutError: get() timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\apps\anaconda3\envs\labscript\lib\threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "c:\apps\anaconda3\envs\labscript\lib\site-packages\runmanager\__init__.py", line 804, in compile_labscript_async
    to_child, from_child, child = process_tree.subprocess(
  File "c:\apps\anaconda3\envs\labscript\lib\site-packages\zprocess\process_tree.py", line 1410, in subprocess
    raise RuntimeError('child process did not connect within the timeout.')
RuntimeError: child process did not connect within the timeout.


Zak V

unread,
Apr 9, 2021, 4:14:03 PM4/9/21
to the labscript suite
Hi Andrew,

When does this error occur? Is it when blacs starts up? Or the first time it attempts to run a shot?

Looking back at the connection table that you provided in the first email in this thread, there's a comment that you are using a dummy pseudoclock but then you seem to be instantiating a real PineBlaster object. Do you actually have a pineblaster connected at 'COM6'? If not then the issue may just be that blacs is attempting to connect to a device that doesn't exist.

Cheers,
Zak

Andrew Blackney

unread,
Apr 9, 2021, 4:31:50 PM4/9/21
to the labscript suite
yes I do have a pine blaster in the system connected via com port 6. thios issue occurs on ssdtartup of blac from the gui icon on the start menu. additonally I also found I get this message when I start runviewer gui:
Traceback (most recent call last):
  File "c:\apps\anaconda3\envs\labscript\lib\site-packages\zprocess\process_tree.py", line 1408, in subprocess
    msg = from_child.get(startup_timeout, interruptor=startup_interruptor)
  File "c:\apps\anaconda3\envs\labscript\lib\site-packages\zprocess\process_tree.py", line 511, in get
    raise TimeoutError('get() timed out')
zprocess.utils.TimeoutError: get() timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\apps\anaconda3\envs\labscript\lib\site-packages\runmanager\__main__.py", line 1839, in <lambda>
    QtCore.QTimer.singleShot(50, lambda: self.check_child_exited(timeout_time, kill))
  File "c:\apps\anaconda3\envs\labscript\lib\site-packages\runmanager\__main__.py", line 1856, in check_child_exited
    self.to_child, self.from_child, self.child = process_tree.subprocess(
  File "c:\apps\anaconda3\envs\labscript\lib\site-packages\zprocess\process_tree.py", line 1410, in subprocess
    raise RuntimeError('child process did not connect within the timeout.')
RuntimeError: child process did not connect within the timeout.



Zak V

unread,
Apr 9, 2021, 5:38:17 PM4/9/21
to the labscript suite
Hmm, we're getting into the regime of stuff that I'm not so familiar with, so maybe Chris or David will have more helpful input than me.

Just to check, that last error you mentioned shows calls from runmanager code. Does it happen when you start runmanager or runviewer? Also as far as I can tell, line 1839 in runmanager\__main__.py should only be run when the runmanager's "restart subprocess" button is clicked so I'm surprised to hear that this error occurs right when a program starts up.

Do you have secure communication enabled in your labconfig? Given that there seem to be some communication issues it might be worth trying to temporarily disable secure communication and see if the issues persist. To try that, set `allow_insecure = True` in the `[security]` section of your labconfig. Note that you'll have to restart the labscript programs for that change to take effect, including killing the background zlog and zlock processes from the task manager (or just restart your computer).

Also, just for some additional context, are you using the labscript programs all on one computer at the moment? Or are you using some on one computer and others on another computer?

-Zak

Reply all
Reply to author
Forward
0 new messages