Swabian Instruments logoContact Sales

Fixing Python Import Errors for Time Tagger

Learn how to fix the two most common Python import errors when using Time Tagger, caused by a missing PYTHONPATH entry or an incompatible NumPy version.

NumPy is the only third-party Python package Time Tagger depends on. Because of this, when importing the Time Tagger Python module fails, the cause is almost always one of two issues: the installation folder is missing from your Python path, or your NumPy version is incompatible with your installed Time Tagger software version.

ModuleNotFoundError: No module named ‘Swabian’

Normally, the installation procedure automatically adds the installation path to your Python path. If the “PYTHONPATH” environment variable is missing, or does not contain the Time Tagger installation path, Python is not able to find the Time Tagger library and import the package.

The error typically appears as:

Traceback (most recent call last):
  File "<ipython-input-3-9d3c3ff1b8d9>", line 10, in <module>
    from Swabian import TimeTagger
ModuleNotFoundError: No module named 'Swabian'

(Older Time Tagger installations may instead show import TimeTagger and No module named 'TimeTagger'; the cause and fix are the same.)

The Time Tagger Python module is installed in its own folder along with other required compiled libraries. By default, it is located in: ‘C:\Program Files\Swabian Instruments\Time Tagger\driver\python\

The Python environment has to be aware of this folder, and it must be in the Python path. You can verify its presence as shown in the example below.

In [1]: import sys

In [2]: sys.path
Out[2]:
['C:\\ProgramData\\Anaconda3\\Scripts',
 'C:\\Program Files\\Swabian Instruments\\Time Tagger\\driver\\python',
 'C:\\ProgramData\\Anaconda3\\python311.zip',
 'C:\\ProgramData\\Anaconda3\\DLLs',
 'C:\\ProgramData\\Anaconda3\\lib',
 'C:\\ProgramData\\Anaconda3',
 'C:\\ProgramData\\Anaconda3\\lib\\site-packages',
 'C:\\ProgramData\\Anaconda3\\lib\\site-packages\\win32',
 'C:\\ProgramData\\Anaconda3\\lib\\site-packages\\win32\\lib',
 'C:\\ProgramData\\Anaconda3\\lib\\site-packages\\Pythonwin',
 'C:\\ProgramData\\Anaconda3\\lib\\site-packages\\IPython\\extensions']

The TimeTagger folder is added by the installer to the Python path through the OS environment variable PYTHONPATH, which lists paths for external modules. You can check that PYTHONPATH has the correct value in the following way:

In [1]: import os
In [2]: os.environ['PYTHONPATH']
Out[2]: 'C:\\Program Files\\Swabian Instruments\\Time Tagger\\driver\\python'

If this variable, for some reason, is not set correctly, it can be fixed manually using Windows tools. PYTHONPATH is set among the global environment variables of Windows, found under My Computer > Properties > Advanced System Settings > Environment Variables .

ModuleNotFoundError: No module named ‘_TimeTagger’

Since release 2.17.4, the Time Tagger software supports NumPy version >= 2.0.0.

If you are using an older version of Time Tagger (<= 2.17.2) together with an updated NumPy version (>= 2.0.0), you will encounter an exception related to the import of numpy.core.multiarray:

Traceback (most recent call last):
  File "C:\Program Files\Swabian Instruments\Time Tagger\driver\python\TimeTagger.py", line 15, in <module>
      import _TimeTagger
ModuleNotFoundError: No module named '_TimeTagger'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "dls\__main__.py", line 5, in <module>
  File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
  File "dls\__init__.py", line 39, in <module>
  File "C:\Program Files\Swabian Instruments\Time Tagger\driver\python\TimeTagger.py", line 36, in <module>
      import _TimeTagger
ImportError: numpy.core.multiarray failed to import

The best way to resolve this issue is to update our software to the latest release, which can be downloaded here. If updating the software is not feasible at the moment, you may instead downgrade NumPy to a suitable 1.x version.

Cookie Policy
We use third party service providers, like Freshworks Inc ("Freshworks") to enable interaction with you on our website and/or our product. As a data processor acting on our behalf, Freshworks automatically receives and records certain information of yours like device model, IP address, the type of browser being used and usage pattern through cookies and browser settings. Freshworks performs analytics on such data on our behalf which helps us improve our service to you. You can read about the cookies Freshworks' sets in their cookie policy here.