I have the cu3 variant, with ARTIQ and Kasli on version 6.7611.9741e4aa. I am having trouble running scripts that involves the core device. Screenshot attached shows the error message. This is the result of running the most basic LED script from here, with the modification of LED to TTL4.

I can run jobs that do not require the use of the core device (and TTLs on my cu3 crate), but as long as I invoke the @kernel decorator, I get this error. I believe I may be missing something, what should I do?

When did this problem begin to occur? IIRC you were already using the system before.

I only realized it today. When I tried it a few months ago on a different computer, everything was fine. I moved artiq_master onto a new computer and installed a newer version of ARTIQ because that is the only one available in conda some weeks back. I have only been using ARTIQ without the TTLs and the core device over the past few weeks, so it is entirely possible that this problem was already there when I moved to this new computer but I just did not realize it until now when I needed the TTLs.

Here's a list of packages installed on this newer machine:

# packages in environment at C:\Users\Mozart\Miniconda3:
#
# Name                    Version                   Build  Channel
aiohttp                   3.7.4            py36h2bbff1b_1  
argon2-cffi               20.1.0           py36h2bbff1b_1  
artiq                     6.7604.040aa6fd               0    https://conda.m-labs.hk/artiq
artiq-comtools            1.1                           0    https://conda.m-labs.hk/artiq
async-timeout             3.0.1            py36haa95532_0  
async_generator           1.10             py36h28b3542_0  
attrs                     21.2.0             pyhd3eb1b0_0  
binutils-or1k-linux       2.30                          0    https://conda.m-labs.hk/artiq
bleach                    3.3.0              pyhd3eb1b0_0  
brotlipy                  0.7.0           py36h2bbff1b_1003  
ca-certificates           2021.4.13            haa95532_1  
cached-property           1.5.2                      py_0  
certifi                   2020.12.5        py36haa95532_0  
cffi                      1.14.5           py36hcd4344a_0  
chardet                   3.0.4           py36haa95532_1003  
colorama                  0.4.4              pyhd3eb1b0_0  
conda                     4.10.1           py36haa95532_1  
conda-package-handling    1.7.3            py36h8cc25b3_1  
console_shortcut          0.1.1                         4  
cryptography              3.4.7            py36h71e12ea_0  
cycler                    0.10.0           py36haa95532_0  
dataclasses               0.8                pyh4f3eec9_6  
decorator                 5.0.9              pyhd3eb1b0_0  
defusedxml                0.7.1              pyhd3eb1b0_0  
entrypoints               0.3                      py36_0  
freetype                  2.10.4               hd328e21_0  
git                       2.23.0               h6bb4b03_0  
h5py                      2.10.0           py36h5e291fa_0  
hdf5                      1.10.4               h7ebc959_0  
icc_rt                    2019.0.0             h0cc432a_1  
icu                       58.2                 ha925a31_3  
idna                      2.10                       py_0  
idna_ssl                  1.1.0            py36haa95532_0  
importlib-metadata        3.10.0           py36haa95532_0  
importlib_metadata        3.10.0               hd3eb1b0_0  
intel-openmp              2021.2.0           haa95532_616  
ipykernel                 5.3.4            py36h5ca1d4c_0  
ipython                   5.8.0                    py36_1    conda-forge
ipython_genutils          0.2.0              pyhd3eb1b0_1  
ipywidgets                7.6.3              pyhd3eb1b0_1  
jinja2                    3.0.0              pyhd3eb1b0_0  
jpeg                      9b                   hb83a4c4_2  
jsonschema                3.2.0                      py_2  
jupyter                   1.0.0                    py36_7  
jupyter_client            6.1.12             pyhd3eb1b0_0  
jupyter_console           5.2.0                    py36_1    conda-forge
jupyter_contrib_core      0.3.3                      py_2    conda-forge
jupyter_contrib_nbextensions 0.5.0                 py36_1000    conda-forge
jupyter_core              4.7.1            py36haa95532_0  
jupyter_highlight_selected_word 0.2.0           py36ha15d459_1002    conda-forge
jupyter_latex_envs        1.4.6           pyhd8ed1ab_1002    conda-forge
jupyter_nbextensions_configurator 0.4.1            py36ha15d459_2    conda-forge
jupyterlab_pygments       0.1.2                      py_0  
jupyterlab_widgets        1.0.0              pyhd3eb1b0_1  
kiwisolver                1.3.1            py36hd77b12b_0  
libblas                   3.9.0                     9_mkl    conda-forge
libcblas                  3.9.0                     9_mkl    conda-forge
libgit2                   1.1.0                h8648793_1    conda-forge
libiconv                  1.15                 h1df5818_7  
liblapack                 3.9.0                     9_mkl    conda-forge
libpng                    1.6.37               h2a8f88b_0  
libsodium                 1.0.18               h62dcd97_0  
libssh2                   1.9.0                h7a1dbc1_1  
libtiff                   4.2.0                hd0e1b90_0  
libxml2                   2.9.10               hb89e7f3_3  
libxslt                   1.1.34               he774522_0  
llvmlite-artiq            0.23.0.dev                    0    https://conda.m-labs.hk/artiq
lxml                      4.6.3            py36h9b66d53_0  
lz4-c                     1.9.3                h2bbff1b_0  
m2w64-gcc-libgfortran     5.3.0                         6  
m2w64-gcc-libs            5.3.0                         7  
m2w64-gcc-libs-core       5.3.0                         7  
m2w64-gmp                 6.1.0                         2  
m2w64-libwinpthread-git   5.0.0.4634.697f757               2  
markupsafe                2.0.0            py36h2bbff1b_0  
matplotlib                3.3.4            py36haa95532_0  
matplotlib-base           3.3.4            py36h49ac443_0  
menuinst                  1.4.16           py36he774522_1  
mistune                   0.8.4            py36he774522_0  
mkl                       2021.2.0           hb70f87d_389    conda-forge
mpmath                    1.2.1            py36haa95532_0  
msys2-conda-epoch         20160418                      1  
multidict                 5.1.0            py36h2bbff1b_2  
nbclient                  0.5.3              pyhd3eb1b0_0  
nbconvert                 6.0.7                    py36_0  
nbformat                  5.1.3              pyhd3eb1b0_0  
nest-asyncio              1.5.1              pyhd3eb1b0_0  
nidaqmx-python            0.5.7                      py_3    conda-forge
notebook                  6.3.0            py36haa95532_0  
numpy                     1.19.5           py36hd1b969e_1    conda-forge
olefile                   0.46                     py36_0  
openssl                   1.1.1k               h2bbff1b_0  
packaging                 20.9               pyhd3eb1b0_0  
pandas                    0.25.3           py36he350917_0    conda-forge
pandoc                    2.12                 haa95532_0  
pandocfilters             1.4.3            py36haa95532_1  
pickleshare               0.7.5           pyhd3eb1b0_1003  
pillow                    8.2.0            py36h4fa10fc_0  
pip                       21.0.1           py36haa95532_0  
powershell_shortcut       0.0.1                         3  
prettytable               2.1.0              pyhd8ed1ab_0    conda-forge
prometheus_client         0.10.1             pyhd3eb1b0_0  
prompt_toolkit            1.0.15                     py_1    conda-forge
pycosat                   0.6.3            py36h2bbff1b_0  
pycparser                 2.20                       py_2  
pygit2                    1.5.0            py36h68aa20f_0    conda-forge
pygments                  2.8.1              pyhd3eb1b0_0  
pyopenssl                 20.0.0             pyhd3eb1b0_1  
pyparsing                 2.4.7              pyhd3eb1b0_0  
pyqt                      5.9.2            py36h6538335_2  
pyqtgraph                 0.11.0                     py_0  
pyreadline                2.1                      py36_1  
pyrsistent                0.17.3           py36he774522_0  
pyserial                  3.5              py36haa95532_0  
pysocks                   1.7.1            py36haa95532_0  
python                    3.6.8                h9f7ef89_7  
python-dateutil           2.8.1              pyhd3eb1b0_0  
python-levenshtein        0.12.2           py36h2bbff1b_0  
python_abi                3.6                     1_cp36m    conda-forge
pythonparser              1.3                           0    https://conda.m-labs.hk/artiq
pytz                      2021.1             pyhd3eb1b0_0  
pyvisa                    1.11.3           py36ha15d459_1    conda-forge
pywin32                   227              py36he774522_1  
pywinpty                  0.5.7                    py36_0  
pyyaml                    5.4.1            py36h2bbff1b_1  
pyzmq                     20.0.0           py36hd77b12b_1  
qasync                    0.10.0                   pypi_0    pypi
qt                        5.9.7            vc14h73c81de_0  
qtconsole                 5.0.3              pyhd3eb1b0_0  
qtpy                      1.9.0                      py_0  
qutip                     4.6.1            py36h010c3f4_0    conda-forge
regex                     2021.4.4         py36h2bbff1b_0  
requests                  2.25.0             pyhd3eb1b0_0  
ruamel_yaml               0.15.100         py36h2bbff1b_0  
scipy                     1.5.3            py36h7ff6e69_0    conda-forge
send2trash                1.5.0              pyhd3eb1b0_1  
setuptools                52.0.0           py36haa95532_0  
simplegeneric             0.8.1                    py36_2  
sip                       4.19.8           py36h6538335_0  
sipyco                    1.2                           0    https://conda.m-labs.hk/artiq
six                       1.15.0           py36haa95532_0  
sqlite                    3.33.0               h2a8f88b_0  
sympy                     1.8              py36haa95532_0  
tbb                       2021.2.0             h59b6b97_0  
terminado                 0.9.4            py36haa95532_0  
testpath                  0.4.4              pyhd3eb1b0_0  
tk                        8.6.10               he774522_0  
tornado                   6.1              py36h2bbff1b_0  
tqdm                      4.54.1             pyhd3eb1b0_0  
traitlets                 4.3.3                    py36_0  
typing-extensions         3.7.4.3              hd3eb1b0_0  
typing_extensions         3.7.4.3            pyh06a4308_0  
tzdata                    2020d                h14c3975_0  
urllib3                   1.25.11                    py_0  
vc                        14.2                 h21ff451_1  
vs2015_runtime            14.27.29016          h5e58377_2  
wcwidth                   0.2.5                      py_0  
webencodings              0.5.1                    py36_1  
wheel                     0.36.1             pyhd3eb1b0_0  
widgetsnbextension        3.5.1                    py36_0  
win_inet_pton             1.1.0            py36haa95532_0  
wincertstore              0.2              py36h7fe50ca_0  
winpty                    0.4.3                         4  
xz                        5.2.5                h62dcd97_0  
yaml                      0.2.5                he774522_0  
yarl                      1.6.3            py36h2bbff1b_0  
zeromq                    4.3.3                ha925a31_3  
zipp                      3.4.1              pyhd3eb1b0_0  
zlib                      1.2.11               h62dcd97_4  
zstd                      1.4.5                h04227a9_0  

Could be a conda bug. Try creating a fresh conda environment.

It looks like it is a combination of the new ARTIQ version and the older Python versions (and maybe this machine with its conda quirks). I tried creating new conda environments with Python 3.6.8 and 3.7.9, and they gave me the same OSError. Uninstalled and reinstalled conda with the 3.8 and 3.9 versions. I am using Python 3.8.10 now (with the conda 3.8 installation and installing for all users) and things seem to be working fine.

9 months later

I have the same issue, I recently installed artiq on nix and flashed Kasli with the current version (version 6.7653.f941e171). I'm using Python 3.8.11. Everything is fine when controlled from the dashboard, but when trying to execute scripts via rpc (inside jupyter lab) with the @kernel decorator I get the following error:
Terminating with exception (OSError: source code not available)
Any idea how this can be resolved?

    robthom trying to execute scripts via rpc (inside jupyter lab) with the @kernel decorator

    Probably unrelated to the OP's issue and some problem with the way you are setting this up. Please describe what you are doing in detail.

    I set up the nix environment according to the manual, flashed Kasli with the new gateware (Kasli v1.1, SU variant). Working with the dashboard is fine, both for scripts which run on Kasli with @kernel and script that don't. However, when I try to send experiments via rpc by executing the following python file (using the LED script from here):

    from artiq import *
    from sipyco.pc_rpc import Client
    schedule = Client("::1", 3251, "master_schedule")
    
    expid_led = {
        'file': 'repository/test/led.py',
        'class_name': 'LED',
        'log_level': 30,
        'arguments': {}}
    
    rid = schedule.submit(pipeline_name="main", expid=expid_led,
            priority=0, due_date=None, flush=False)

    I get the following error:

    ERROR:worker(942,led.py):root:Terminating with exception (OSError: source code not available)
    Traceback (most recent call last):
    File "/nix/store/ipbd9hg3z39kd5xizysmdlwv4vd24vbk-python3-3.8.11-env/lib/python3.8/site-packages/artiq/master/worker_impl.py", line 300, in main
    exp_inst.run()
    File "/nix/store/ipbd9hg3z39kd5xizysmdlwv4vd24vbk-python3-3.8.11-env/lib/python3.8/site-packages/artiq/language/core.py", line 54, in run_on_core
    return getattr(self, arg).run(run_on_core, ((self,) + k_args), k_kwargs)
    File "/nix/store/ipbd9hg3z39kd5xizysmdlwv4vd24vbk-python3-3.8.11-env/lib/python3.8/site-packages/artiq/coredevice/core.py", line 129, in run
    self.compile(function, args, kwargs, set_result)
    File "/nix/store/ipbd9hg3z39kd5xizysmdlwv4vd24vbk-python3-3.8.11-env/lib/python3.8/site-packages/artiq/coredevice/core.py", line 104, in compile
    stitcher.stitch_call(function, args, kwargs, set_result)
    File "/nix/store/ipbd9hg3z39kd5xizysmdlwv4vd24vbk-python3-3.8.11-env/lib/python3.8/site-packages/artiq/compiler/embedding.py", line 691, in stitch_call
    call_node = synthesizer.call(function, args, kwargs, callback)
    File "/nix/store/ipbd9hg3z39kd5xizysmdlwv4vd24vbk-python3-3.8.11-env/lib/python3.8/site-packages/artiq/compiler/embedding.py", line 363, in call
    callee_node = self.quote(callee)
    File "/nix/store/ipbd9hg3z39kd5xizysmdlwv4vd24vbk-python3-3.8.11-env/lib/python3.8/site-packages/artiq/compiler/embedding.py", line 257, in quote
    function_type = self.quote_function(value, self.expanded_from)
    File "/nix/store/ipbd9hg3z39kd5xizysmdlwv4vd24vbk-python3-3.8.11-env/lib/python3.8/site-packages/artiq/compiler/embedding.py", line 1088, in _quote_function
    self._quote_embedded_function(function,
    File "/nix/store/ipbd9hg3z39kd5xizysmdlwv4vd24vbk-python3-3.8.11-env/lib/python3.8/site-packages/artiq/compiler/embedding.py", line 860, in _quote_embedded_function
    source_code = inspect.getsource(embedded_function)
    File "/nix/store/j2hdhabhzvwy7zbw96pi7m7i066snh2i-python3-3.8.11/lib/python3.8/inspect.py", line 997, in getsource
    lines, lnum = getsourcelines(object)
    File "/nix/store/j2hdhabhzvwy7zbw96pi7m7i066snh2i-python3-3.8.11/lib/python3.8/inspect.py", line 979, in getsourcelines
    lines, lnum = findsource(object)
    File "/nix/store/j2hdhabhzvwy7zbw96pi7m7i066snh2i-python3-3.8.11/lib/python3.8/inspect.py", line 790, in findsource
    raise OSError('source code not available')
    OSError: source code not available
    ERROR:master:artiq.master.scheduler:got worker exception in run stage, deleting RID 942
    !<

    However, when sending an experiment that does not need the core device it works fine. I see in both cases the experiments appearing in the schedule of the dashboard. Everything is run from the same pc at the moment (but I would like to be able to run experiments remotely via jupyter server).

    Can you print the expid in the experiment when you run it from the dashboard (print(self.scheduler.expid)) and compare with what you are sending?

    I get the following, seems similar to me except the file location:
    print:{'log_level': 30, 'file': 'test/led.py', 'class_name': 'LED', 'arguments': {}, 'repo_rev': 'N/A'}
    I will try to get it working with the same file location. But up to now I always get the error No such file or directory: 'test/led.py' when running the file from above with 'file': 'test/led.py' (both when running it in the folder artiq-master and artiq-master/repository)

    Seems like adding 'repo_rev': 'N/A' to the expid and changing the path to 'file': 'test/led.py' solved the issue, thanks for the hint.