Closed lankes-fzj closed 4 years ago
i would also submit this question to MATLAB via their support request system, out of curiousity.
I can't think of why this would happen... Out of curiosity, would you mind trying to change the line 7 in qcodes init.py file to from qcodes import configuration as qcconfig
and try to import qcodes in matlab again?
I've tried your suggestion to change the import line and it works for this line, but the error now occurs at another line: import qcodes.utils.validators as vals
. It looked like it might have something to do with the import ... as
statements.
So I've changed all of them to from .. import .. as
and now importing qcodes from MATLAB is working fine. Thank you for that 👍
For development this soultion is sufficient for me, but I will also try to setup my environment without Anaconda (in a vm to not mess up my host system) to see if this is the reason. I will give you an update, if it works.
Using Python without Anaconda would also be solution to this problem. Maybe this is more suitable for other Qcodes users, but I think I still prefer astafan's workaround.
During testing I encountered another problem: The first import attempt always fails because h5py
cannot load a DLL. The second import attempt, however, always seems to work. But this is not your problem, as there are already many issues about this problem in other projects using h5py. Therefore I will look for a solution there first.
Since many projects in my institute are developed with MATLAB, I am currently trying to implement a MATLAB interface for our Qcodes instruments. This would allow the instruments to be used from MATLAB scripts.
In general, it's very easy to call Python-scripts from MATLAB or to import modules from Python into MATLAB. Unfortunately, this doesn't work with qcodes. I'm always getting the following error.
By
__init__><module>
here theqcodes.__init__
module is meantIf already tried to use different MATLAB versions and to reinstall Qcodes and its dependencies, but without any success. If I import Qcodes directly from Python (e.g. IPython console) it works fine.
Probably this is not Qcodes-problem, but problem with MATLAB's Python interface. But maybe someone here has had similar experiences and could give me some advice.
Steps to reproduce
After this you may have to restart MATLAB (remember starting it from the right conda-environment)
Expected behaviour
I would expect MATLAB to import the certain module, as it does for other packages. This also works with Qcodes, but only with some sources, like some files from
utils
:Actual behaviour
Instead importing files on
qcodes.configuration
:System
operating system Windows 10 Pro 64-bit
qcodes branch master (latest version 0.16.0 from pip)
qcodes commit 66222eb8cc4ab1ab2cdadb94da827f94436b4af7
MATLAB 2018a Also tested with: 2020a
Python 3.6 Also tried with: 3.7