Hello,
I am trying to compile idle.py onto a Kasli FPGA using the artiq_compile idle.py command. I am getting the following error upon running:
** IDLE can't import Tkinter.
Your Python may not be configured for Tk. **

I looked online and this seems to be a problem that isn't specific to Artiq; however, all the different troubleshooting methods I found online pertain to the regular installation of python, and I found that none of these methods were applicable to the installation of python for Artiq on nix.

Is there a way to import Tk into the nix Python installation that Artiq is using?

System Configuration:
Kasli
OS: Linux 20.04
Arch. : x86, 64b
software ident 7.8053.cf8e583.beta
gateware ident 7.8053.cf8e583.beta

Please post exact commands, exact error message, idle.py, flake.nix and flake.lock

Here is the command used:
artiq_compile idle.py
and the subsequent error message:

** IDLE can't import Tkinter.
Your Python may not be configured for Tk. **

Below are the files. Another thing I want to point out is that idle.py was not originally in the directory containing device_db.py. I could not find the idle.py from the directory where I flashed the Artiq-7 gateware nor in any other similar directories. I had to pull the idle.py file from a folder in the nix store and copy it into the directory with device_db.py to get that error message.

idle.py

import os.path
import sys


# Enable running IDLE with idlelib in a non-standard location.
# This was once used to run development versions of IDLE.
# Because PEP 434 declared idle.py a public interface,
# removal should require deprecation.
idlelib_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if idlelib_dir not in sys.path:
    sys.path.insert(0, idlelib_dir)

from idlelib.pyshell import main  # This is subject to change
main()

flake.nix

{
  inputs.artiq.url = "git+https://github.com/m-labs/artiq.git";
  inputs.extrapkg.url = "git+https://git.m-labs.hk/M-Labs/artiq-extrapkg.git";
  inputs.extrapkg.inputs.artiq.follows = "artiq";
  outputs = { self, artiq, extrapkg }:
    let
      pkgs = artiq.inputs.nixpkgs.legacyPackages.x86_64-linux;
      aqmain = artiq.packages.x86_64-linux;
      aqextra = extrapkg.packages.x86_64-linux;
    in {
      defaultPackage.x86_64-linux = pkgs.buildEnv {
        name = "artiq-env";
        paths = [
          # ========================================
          # EDIT BELOW
          # ========================================
          (pkgs.python3.withPackages(ps: [
            # List desired Python packages here.
            aqmain.artiq
            ps.paramiko  # needed if and only if flashing boards remotely (artiq_flash -H)
            aqextra.flake8-artiq

            # The NixOS package collection contains many other packages that you may find
            # interesting. Here are some examples:
            #ps.pandas
            #ps.numpy
            #ps.scipy
            #ps.numba
            #ps.matplotlib
            # or if you need Qt (will recompile):
            #(ps.matplotlib.override { enableQt = true; })
            #ps.bokeh
            #ps.cirq
            #ps.qiskit
          ]))
          #aqextra.korad_ka3005p
          #aqextra.novatech409b
          # List desired non-Python packages here
          aqmain.openocd-bscanspi  # needed if and only if flashing boards
          # Other potentially interesting packages from the NixOS package collection:
          #pkgs.gtkwave
          #pkgs.spyder
          #pkgs.R
          #pkgs.julia
          # ========================================
          # EDIT ABOVE
          # ========================================
        ];
      };
    };
}

flake.lock

{
  "nodes": {
    "artiq": {
      "inputs": {
        "artiq-comtools": "artiq-comtools",
        "mozilla-overlay": "mozilla-overlay",
        "nixpkgs": "nixpkgs",
        "sipyco": "sipyco",
        "src-migen": "src-migen",
        "src-misoc": "src-misoc",
        "src-pythonparser": "src-pythonparser"
      },
      "locked": {
        "lastModified": 1654087576,
        "narHash": "sha256-d+LCvCXikhhEjsf4qBZakx3Sda85p+4vVZVwE1YuS90=",
        "ref": "master",
        "rev": "68ef0073ea66fe9c7f7c178979ecb8c681c47caa",
        "revCount": 8068,
        "type": "git",
        "url": "https://github.com/m-labs/artiq.git"
      },
      "original": {
        "type": "git",
        "url": "https://github.com/m-labs/artiq.git"
      }
    },
    "artiq-comtools": {
      "inputs": {
        "nixpkgs": [
          "artiq",
          "nixpkgs"
        ],
        "sipyco": [
          "artiq",
          "sipyco"
        ]
      },
      "locked": {
        "lastModified": 1654007592,
        "narHash": "sha256-vaDFhE1ItjqtIcinC/6RAJGbj44pxxMUEeQUa3FtgEE=",
        "owner": "m-labs",
        "repo": "artiq-comtools",
        "rev": "cb73281154656ee8f74db1866859e31bf42755cd",
        "type": "github"
      },
      "original": {
        "owner": "m-labs",
        "repo": "artiq-comtools",
        "type": "github"
      }
    },
    "extrapkg": {
      "inputs": {
        "artiq": [
          "artiq"
        ]
      },
      "locked": {
        "lastModified": 1653637071,
        "narHash": "sha256-1shbXZq7YBl2kM80tqJXOkeMhI63L7dZnXpBuBWG0qk=",
        "ref": "master",
        "rev": "3b74a608dfec4ae7ea9860e20a8adf334bae49ad",
        "revCount": 24,
        "type": "git",
        "url": "https://git.m-labs.hk/M-Labs/artiq-extrapkg.git"
      },
      "original": {
        "type": "git",
        "url": "https://git.m-labs.hk/M-Labs/artiq-extrapkg.git"
      }
    },
    "mozilla-overlay": {
      "flake": false,
      "locked": {
        "lastModified": 1650459918,
        "narHash": "sha256-sroCK+QJTmoXtcRkwZyKOP9iAYOPID2Bwdxn4GkG16w=",
        "owner": "mozilla",
        "repo": "nixpkgs-mozilla",
        "rev": "e1f7540fc0a8b989fb8cf701dc4fd7fc76bcf168",
        "type": "github"
      },
      "original": {
        "owner": "mozilla",
        "repo": "nixpkgs-mozilla",
        "type": "github"
      }
    },
    "nixpkgs": {
      "locked": {
        "lastModified": 1653920503,
        "narHash": "sha256-BBeCZwZImtjP3oYy4WogkQYy5OxNyfNciVSc1AfZgLQ=",
        "owner": "NixOS",
        "repo": "nixpkgs",
        "rev": "a634c8f6c1fbf9b9730e01764999666f3436f10a",
        "type": "github"
      },
      "original": {
        "owner": "NixOS",
        "ref": "nixos-22.05",
        "repo": "nixpkgs",
        "type": "github"
      }
    },
    "root": {
      "inputs": {
        "artiq": "artiq",
        "extrapkg": "extrapkg"
      }
    },
    "sipyco": {
      "inputs": {
        "nixpkgs": [
          "artiq",
          "nixpkgs"
        ]
      },
      "locked": {
        "lastModified": 1654006751,
        "narHash": "sha256-OWAnoTCutvTQcYdtdtLQuL6uRtG+7Jz7sbRhcScv8bo=",
        "owner": "m-labs",
        "repo": "sipyco",
        "rev": "b3d03a94c751a24769c54a61a0dbe9d6af52dade",
        "type": "github"
      },
      "original": {
        "owner": "m-labs",
        "repo": "sipyco",
        "type": "github"
      }
    },
    "src-migen": {
      "flake": false,
      "locked": {
        "lastModified": 1650337393,
        "narHash": "sha256-rm1SlFmF2ASz0vIy2nDEzGlyRw2oYNeJRr8Kh8Mg2Qc=",
        "owner": "m-labs",
        "repo": "migen",
        "rev": "d4e3f34177c32f09904397179e6ed9c83175e528",
        "type": "github"
      },
      "original": {
        "owner": "m-labs",
        "repo": "migen",
        "type": "github"
      }
    },
    "src-misoc": {
      "flake": false,
      "locked": {
        "lastModified": 1649324486,
        "narHash": "sha256-Mw/fQS3lHFvCm7L1k63joRkz5uyijQfywcOq+X2+o2s=",
        "ref": "master",
        "rev": "f1dc58d2b8c222ba41c25cee4301626625f46e43",
        "revCount": 2420,
        "submodules": true,
        "type": "git",
        "url": "https://github.com/m-labs/misoc.git"
      },
      "original": {
        "submodules": true,
        "type": "git",
        "url": "https://github.com/m-labs/misoc.git"
      }
    },
    "src-pythonparser": {
      "flake": false,
      "locked": {
        "lastModified": 1628745371,
        "narHash": "sha256-p6TgeeaK4NEmbhimEXp31W8hVRo4DgWmcCoqZ+UdN60=",
        "owner": "m-labs",
        "repo": "pythonparser",
        "rev": "5413ee5c9f8760e95c6acd5d6e88dabb831ad201",
        "type": "github"
      },
      "original": {
        "owner": "m-labs",
        "repo": "pythonparser",
        "type": "github"
      }
    }
  },
  "root": "root",
  "version": 7
}

Why would you want to run IDLE on the core device? That's not going to work.

What you probably really want is to use an experiment you wrote yourself and artiq_compile that.

I was trying to configure the core device. I tried following the instructions found here: https://m-labs.hk/artiq/manual-beta/installing.html#miscellaneous-configuration-of-the-core-device
Here are the commands that I was trying to run:

artiq_compile idle.py
artiq_coremgmt config write -f idle_kernel idle.elf

The reason I thought this was the problem was because when I ran artiq_coremgmt log, I get the following log:

[     0.000013s]  INFO(runtime): ARTIQ runtime starting...
[     0.003937s]  INFO(runtime): software ident 7.8053.cf8e583.beta
[     0.010301s]  INFO(runtime): gateware ident 7.8053.cf8e583.beta
[     0.016674s]  INFO(runtime): log level set to INFO by default
[     0.022402s]  INFO(runtime): UART log level set to INFO by default
[     0.028790s]  WARN(runtime::rtio_clocking): rtio_clock setting not recognised. Falling back to default.
[     0.037974s]  INFO(runtime::rtio_clocking): using internal 125MHz RTIO clock
[     0.314473s]  INFO(board_artiq::si5324): waiting for Si5324 lock...
[     7.348787s]  INFO(board_artiq::si5324):   ...locked
[     7.352431s]  INFO(runtime::rtio_clocking::crg): Using internal RTIO clock
[     7.359587s]  INFO(runtime): network addresses: MAC=80-1f-12-5d-aa-94 IPv4=192.168.1.74 IPv6-LL=fe80::821f:12ff:fe5d:aa94 IPv6=no configured address
[     7.374342s]  INFO(runtime::mgmt): management interface active
[     7.386660s]  INFO(runtime::session): accepting network sessions
[     7.399931s]  INFO(runtime::session): running startup kernel
[     7.404397s]  INFO(runtime::session): no startup kernel found
[     7.410212s]  INFO(runtime::session): no connection, starting idle kernel
[     7.417048s]  INFO(runtime::session): no idle kernel found
[    44.892138s]  INFO(runtime::session): new connection from 192.168.1.1:34392
[    44.940406s]  INFO(runtime::session): no connection, starting idle kernel
[    44.946116s]  INFO(runtime::session): no idle kernel found
[  2271.301577s]  INFO(runtime::mgmt): new connection from 192.168.1.1:38498

where the startup kernel and the idle kernel are missing. I'm not sure the way to go about installing the kernel onto the FPGA. The missing kernels have been preventing me from running simple python files using artiq_run and running files using the dashboard. Is there a way to get the kernels onto the FPGA to handle the startup and idle periods?

Idle and startup kernels re not required. Their absence is certainly not preventing you from running things. The message is merely INFOrmative.

The way to get them into the device is what's described on the manual section you cite.

    rjo I looked into my problem with the kernels, and it the problems I'm encountering when running artiq_run are caused by software and gateware version mismatches (I found this based on this Github Issues page https://github.com/m-labs/artiq/issues/1754).; however, after I changed the software version to match the gateware version, I kept on getting the same error when running using artiq_run. The error that I keep on getting is:
    artiq.coredevice.comm_kernel.LoadError: cannot load kernel: parse error: not a shared library for current architecture
    In that Github Issues page, the error stems from major version changes (From Artiq-6 and below to Artiq-7) due to the different ISA with RISC; however, my version differences were within Artiq-7 (The difference being Artiq-7.8053.cf8e583.beta and Artiq-7.8056.d478086.beta). I tried running the command artiq_coremgmt log to see the log of the FPGA, but I get a similar error message as to that on the issues page. My error message is:

    [   610.828718s] ERROR(runtime::session): idle kernel aborted: cannot load kernel: parse error: not a shared library for current architecture
    [   610.840160s]  INFO(runtime::session): no connection, starting idle kernel

    which gets repeated multiple times across different time stamps.
    My guess is that this error is the root of the error I originally got (as seen on Post 1 and 3); however, I don't know of anyway to fix this error. I tried reflashing the gateware that I was given, but I still come across these errors.

    Just make sure those three match:

    • Version of ARTIQ used to generate the device database
    • Version of the ARTIQ software installed on your computer
    • Version of the ARTIQ firmware flashed into the device

    tkinter/IDLE has absolutely nothing to do with this.

      3 months later

      Hi,How to solve the problem? I encounter the same problem, but my software version is matched to the gateware version, thay are all 7.8.
      Thank you very much.

        sb10q Just make sure those three match:

        Like this.

        zixiao but my software version is matched to the gateware version, thay are all 7.8.

        I'm pretty sure it isn't. And there is no "7.8" version.