Closed zakv closed 4 years ago
Hi Zak,
Userlib itself isn't intended to be importable, rather its contents are. So for example a module foo
as userlib/labscriptlib/foo.py
is importable as import labscriptlib.foo
If you need a general-purpose dumping ground for Python modules, that's what pythonlib
is intended for. A module bar
as userlib/pythonlib/bar.py
is importable as import bar
.
(Since pythonlib is in userlib (perhaps a bad decision), bar
may also be imported as import pythonlib.bar
, but that's not advised)
As a side effect of the way the labscript suite installation used to work under mercurial, userlib was directly importable - this was because its parent directory (where the labscript suite modules were located) was added to the python path. That was not ideal (lots of random things in the labscript suite install directory were importable as a result), and is not the case anymore after the move to git and standard packaging techniques.
So I think this is working as intended! If you can confirm you're able to import your stuff given this explanation, then I'll close this issue. And let me know if I've misunderstood anything!
Ah I see, I've been writing all of my imports relative to userlib. I think I had somehow tripped the double import denier long ago and decided to always include userlib.
in the import. Anyway just removing the leading userlib.
from imports should be an easy fix, thanks for the help!
Hi All,
I'm attempting to get labscript running on a new computer with an anaconda developer install on Windows. The installation runs fine but I'm not able to import
userlib
, even after runninglabscript-profile-create
. Instead I getModuleNotFoundError: No module named 'userlib'
. This occurs even with the default values in the labconfig. I'm able to importpythonlib
just fine though.In an interactive session I checked
sys.path
and it includedC:\Users\UserName\labscript-suite\userlib
andC:\Users\UserName\labscript-suite\userlib\pythonlib
. I tried editingsys.path
to move each of those up one directory, sosys.path
then containedC:\Users\UserName\labscript-suite
andC:\Users\UserName\labscript-suite\userlib
. After that I was able to import bothuserlib
andpythonlib
in that interactive session without error.Maybe the parent directories of
userlib
andpythonlib
should be added to path instead? https://github.com/labscript-suite/labscript-utils/blob/2c7deba0b5c091b44a877f1cfe058df9b7d612aa/labscript_profile/__init__.py#L44-L60Somewhat related: https://github.com/labscript-suite/labscript-utils/issues/43
This seems like an issue that others would have run into before so there may be something different about my set up somehow. Maybe it's because this computer never had a mercurial install of labscript on it? I checked
sys.path
on one of our other computers which still has a mercurial labscript install on it, and it included the paths to all three ofC:\Users\UserName\labscript-suite
,C:\Users\UserName\labscript-suite\userlib
andC:\Users\UserName\labscript-suite\userlib\pythonlib
,Cheers, Zak