distutils double import error

138 views
Skip to first unread message

Trey Porto

unread,
Jun 23, 2022, 6:49:30 PM6/23/22
to the labscript suite
We successfully installed labscript on one lab computer some months ago. Today we tried to (anaconda) developer install labscript on a new computer (following these instructions  Developer installation (Anaconda Cloud) — labscript suite | the labscript suite  ) and we got this error. 

Traceback (most recent call last):
  File "c:\users\rbybt\labscript-suite\labscript-utils\labscript_utils\double_import_denier.py", line 72, in find_spec
    self._raise_error(path, fullname, tb, other_name, other_tb)
  File "c:\users\rbybt\labscript-suite\labscript-utils\labscript_utils\double_import_denier.py", line 136, in _raise_error
    raise RuntimeError(msg) from None
RuntimeError: Double import! The same file has been imported under two different names, resulting in two copies of the module. This is almost certainly a mistake. If you are running a script from within a package and want to import another submodule of that package, import it by its full path: 'import module.submodule' instead of just 'import submodule.'

Path imported: C:\Users\RbYbT\anaconda3\envs\P38\Lib\site-packages\setuptools\_distutils\__init__.py

Traceback (first time imported, as setuptools._distutils):
------------
  File "c:\users\rbybt\labscript-suite\runmanager\runmanager\__main__.py", line 53, in <module>
    from labscript_utils.ls_zprocess import zmq_get, ProcessTree, ZMQServer
  File "c:\users\rbybt\labscript-suite\labscript-utils\labscript_utils\ls_zprocess.py", line 16, in <module>
    from distutils.version import LooseVersion
  File "c:\users\rbybt\labscript-suite\labscript-utils\labscript_utils\double_import_denier.py", line 57, in find_spec
    spec = importlib.util.find_spec(fullname, path)
  File "C:\Users\RbYbT\anaconda3\envs\P38\lib\importlib\util.py", line 103, in find_spec
    return _find_spec(fullname, parent_path)
  File "C:\Users\RbYbT\anaconda3\envs\P38\lib\site-packages\_distutils_hack\__init__.py", line 90, in find_spec
    return method()
  File "C:\Users\RbYbT\anaconda3\envs\P38\lib\site-packages\_distutils_hack\__init__.py", line 101, in spec_for_distutils
    mod = importlib.import_module('setuptools._distutils')
  File "C:\Users\RbYbT\anaconda3\envs\P38\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "C:\Users\RbYbT\anaconda3\envs\P38\lib\site-packages\setuptools\__init__.py", line 8, in <module>
    import _distutils_hack.override  # noqa: F401
  File "C:\Users\RbYbT\anaconda3\envs\P38\lib\site-packages\_distutils_hack\override.py", line 1, in <module>
    __import__('_distutils_hack').do_override()
  File "C:\Users\RbYbT\anaconda3\envs\P38\lib\site-packages\_distutils_hack\__init__.py", line 72, in do_override
    ensure_local_distutils()
  File "C:\Users\RbYbT\anaconda3\envs\P38\lib\site-packages\_distutils_hack\__init__.py", line 55, in ensure_local_distutils
    importlib.import_module('distutils')
  File "C:\Users\RbYbT\anaconda3\envs\P38\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "C:\Users\RbYbT\anaconda3\envs\P38\lib\site-packages\_distutils_hack\__init__.py", line 90, in find_spec
    return method()
  File "C:\Users\RbYbT\anaconda3\envs\P38\lib\site-packages\_distutils_hack\__init__.py", line 101, in spec_for_distutils
    mod = importlib.import_module('setuptools._distutils')
  File "C:\Users\RbYbT\anaconda3\envs\P38\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
------------

Traceback (second time imported, as distutils):
------------
  File "c:\users\rbybt\labscript-suite\runmanager\runmanager\__main__.py", line 53, in <module>
    from labscript_utils.ls_zprocess import zmq_get, ProcessTree, ZMQServer
  File "c:\users\rbybt\labscript-suite\labscript-utils\labscript_utils\ls_zprocess.py", line 16, in <module>
    from distutils.version import LooseVersion
------------Traceback (most recent call last):
  File "c:\users\rbybt\labscript-suite\labscript-utils\labscript_utils\double_import_denier.py", line 72, in find_spec
    self._raise_error(path, fullname, tb, other_name, other_tb)
  File "c:\users\rbybt\labscript-suite\labscript-utils\labscript_utils\double_import_denier.py", line 136, in _raise_error
    raise RuntimeError(msg) from None
RuntimeError: Double import! The same file has been imported under two different names, resulting in two copies of the module. This is almost certainly a mistake. If you are running a script from within a package and want to import another submodule of that package, import it by its full path: 'import module.submodule' instead of just 'import submodule.'

Path imported: C:\Users\RbYbT\anaconda3\envs\P38\Lib\site-packages\setuptools\_distutils\__init__.py

Traceback (first time imported, as setuptools._distutils):
------------
  File "c:\users\rbybt\labscript-suite\runmanager\runmanager\__main__.py", line 53, in <module>
    from labscript_utils.ls_zprocess import zmq_get, ProcessTree, ZMQServer
  File "c:\users\rbybt\labscript-suite\labscript-utils\labscript_utils\ls_zprocess.py", line 16, in <module>
    from distutils.version import LooseVersion
  File "c:\users\rbybt\labscript-suite\labscript-utils\labscript_utils\double_import_denier.py", line 57, in find_spec
    spec = importlib.util.find_spec(fullname, path)
  File "C:\Users\RbYbT\anaconda3\envs\P38\lib\importlib\util.py", line 103, in find_spec
    return _find_spec(fullname, parent_path)
  File "C:\Users\RbYbT\anaconda3\envs\P38\lib\site-packages\_distutils_hack\__init__.py", line 90, in find_spec
    return method()
  File "C:\Users\RbYbT\anaconda3\envs\P38\lib\site-packages\_distutils_hack\__init__.py", line 101, in spec_for_distutils
    mod = importlib.import_module('setuptools._distutils')
  File "C:\Users\RbYbT\anaconda3\envs\P38\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "C:\Users\RbYbT\anaconda3\envs\P38\lib\site-packages\setuptools\__init__.py", line 8, in <module>
    import _distutils_hack.override  # noqa: F401
  File "C:\Users\RbYbT\anaconda3\envs\P38\lib\site-packages\_distutils_hack\override.py", line 1, in <module>
    __import__('_distutils_hack').do_override()
  File "C:\Users\RbYbT\anaconda3\envs\P38\lib\site-packages\_distutils_hack\__init__.py", line 72, in do_override
    ensure_local_distutils()
  File "C:\Users\RbYbT\anaconda3\envs\P38\lib\site-packages\_distutils_hack\__init__.py", line 55, in ensure_local_distutils
    importlib.import_module('distutils')
  File "C:\Users\RbYbT\anaconda3\envs\P38\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "C:\Users\RbYbT\anaconda3\envs\P38\lib\site-packages\_distutils_hack\__init__.py", line 90, in find_spec
    return method()
  File "C:\Users\RbYbT\anaconda3\envs\P38\lib\site-packages\_distutils_hack\__init__.py", line 101, in spec_for_distutils
    mod = importlib.import_module('setuptools._distutils')
  File "C:\Users\RbYbT\anaconda3\envs\P38\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
------------

Traceback (second time imported, as distutils):
------------
  File "c:\users\rbybt\labscript-suite\runmanager\runmanager\__main__.py", line 53, in <module>
    from labscript_utils.ls_zprocess import zmq_get, ProcessTree, ZMQServer
  File "c:\users\rbybt\labscript-suite\labscript-utils\labscript_utils\ls_zprocess.py", line 16, in <module>
    from distutils.version import LooseVersion
------------

Trey Porto

unread,
Jun 23, 2022, 10:52:56 PM6/23/22
to the labscript suite
apologies,  I just realized the post got sent before I had finished. Here the full post:

We successfully installed labscript on one lab computer some months ago. Today we tried to (anaconda) developer install labscript on a new computer (following these instructions  Developer installation (Anaconda Cloud) — labscript suite | the labscript suite  ) and we got this error. 
(see below,  a double import! error on distutils )  After what looks like a successful install, the error shows up when we start runmanager or blacs.

The first time we installed and tried to run labscript, we  were using a slightly out of date labscript fork.  Since the one of the only references to distutils we could find was the recent removal of distutils (https://github.com/labscript-suite/labscript-utils/pull/86 ), we updated our forked repository to the latest labscript master build, and repeated the process ( creating a new python environment, cloning our (newly updated) labscript repository, and installing labscript) and surprisingly we got the same error.  I suspect a git problem, but didnt' have time to investigate.

I thought I'd ask the crowd and maybe save some time... any thoughts?

Windows 10

Cheers,
Trey





Trey Porto

unread,
Jun 24, 2022, 1:55:39 AM6/24/22
to the labscript suite
UPDATE: 

doing the entire install procedure ( new python environment, clone repository, install labscript ) gives the same error on my mac OS ... 

I'''m at a loss

Trey

Ian B. Spielman

unread,
Jun 24, 2022, 2:06:20 AM6/24/22
to 'Philip Starkey' via the labscript suite
I am traveling so I can’t be as helpful as I would like, but this results from a recent change in python itself in distutils. My workaround goes as follows:

Open up the double import double_import_denier.py file and look for a hard coded white list of packages, say it WHITELIST = […] (it includes tensor flow). Don’t change it, just note it.

Then right at the beginning of your script import double_import_denier and then do double_import_denier.WHITELIST.append('distutils')

This may not be exact since I don’t have the script handy, but this (or something morally equivalent) did the trick without modifying labscrtipt.

Ian B. Spielman

Fellow, Joint Quantum Institute
National Institute of Standards and Technology and the University of Maryland

----- WEB -----
http://ultracold.jqi.umd.edu

----- EMAIL -----
spie...@jqi.umd.edu

----- ZOOM -----
https://umd.zoom.us/j/7984811536

----- PHONE -----
(301) 246-2482

----- MAIL -----
UMD:
2207 Computer & Space Sciences Bldg.
College Park, MD 20742

NIST:
100 Bureau Drive, Stop 8424
Gaithersburg, MD 20899-8424 USA

----- OFFICE -----
UMD: Physical Sciences Complex, Room 2153
NIST: Building 216, Room B131
> --
> 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/a931d3e3-3fce-4def-8b24-902a43e080edn%40googlegroups.com.

Trey Porto

unread,
Jun 24, 2022, 11:12:28 AM6/24/22
to the labscript suite
Hi Ian,
Thank you for the quick response... when you say:

Then right at the beginning of your script import double_import_denier and then do double_import_denier.WHITELIST.append('distutils')

which file is "your script" ?

thanks,

Trey

Ian B. Spielman

unread,
Jun 24, 2022, 2:32:25 PM6/24/22
to 'Philip Starkey' via the labscript suite
Probably at the beginning of the connection table.

Ian B. Spielman

Fellow, Joint Quantum Institute
National Institute of Standards and Technology and the University of Maryland

----- WEB -----
http://ultracold.jqi.umd.edu

----- EMAIL -----
spie...@jqi.umd.edu

----- ZOOM -----
https://umd.zoom.us/j/7984811536

----- PHONE -----
(301) 246-2482

----- MAIL -----
UMD:
2207 Computer & Space Sciences Bldg.
College Park, MD 20742

NIST:
100 Bureau Drive, Stop 8424
Gaithersburg, MD 20899-8424 USA

----- OFFICE -----
UMD: Physical Sciences Complex, Room 2153
NIST: Building 216, Room B131

> To view this discussion on the web, visit https://groups.google.com/d/msgid/labscriptsuite/95ba3512-30a5-4a11-b535-45b3e5cd0d94n%40googlegroups.com.

dihm....@gmail.com

unread,
Jun 24, 2022, 5:18:34 PM6/24/22
to the labscript suite
Ugh. This stupid thing again. The whole point of  https://github.com/labscript-suite/labscript-utils/pull/86 was to prevent this exact problem, so it's a bit annoying that it is still present. What Ian says will definitely work to get around this. 

But if you didn't mind doing a little digging, I'd be very curious to know what your local `labscript_utils.ls_process.py` file says for line 16. If it's properly up to date with master, it should read `from packaging.version import Version` instead of `from distutils.version import LooseVersion`. If it says the latter, I suspect the linked PR didn't get applied properly to your fork.

-David

Trey Porto

unread,
Jun 24, 2022, 7:09:07 PM6/24/22
to labscri...@googlegroups.com
HI David,

I believe in the end it was a git problem on my end: the repository I was cloning was not the version of labscriipt that I thought it was, and my inexperience with git contributed to my failing to get it merged with the lab script-suite master.  After some time, a wiser me has brought our labscript-suite fork up to date, and at least on my mac,  a fresh install works. I’ll try it on the lab PC’s when I get in.

APPARENTLY SOLVED 

thanks,

Trey


Dr. Trey Porto

Fellow, Joint Quantum Institute
National Institute of Standards and Technology
and the University of Maryland
College Park, MD 20742
UMD Office: PSC 2147
UMD Phone: 301-405-0854
Preferred e-mail: po...@jqi.umd.edu
Official NIST Business: tr...@nist.gov

You received this message because you are subscribed to a topic in the Google Groups "the labscript suite" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/labscriptsuite/MsqmA9GQcyM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to labscriptsuit...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/labscriptsuite/9d55ed02-ba4d-4b5b-92a5-33fcb7368763n%40googlegroups.com.

David Meyer

unread,
Jun 25, 2022, 6:49:34 PM6/25/22
to labscri...@googlegroups.com
I totally understand. Git still gets the better of me on a pretty regular basis. Glad you are sorted out. Nothing's worse than getting things installed only to have a bug prevent you from even starting things.

Best,
-David


Reply all
Reply to author
Forward
0 new messages