LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW calling Python with virtual environment

I am trying to call some python code from LabVIEW, and the code needs to import pythonnet.  When running the python code from PyCharm it uses venv (virtual environment) to add the dependent libraries.  I was watching "Webinar Reminder: [AMER] Python and NI: Using Python with NI Hardware and Software" today and they said that virtual environments aren't supported in LabVIEW, but that there was a work around.  I can't find that workaround documented anywhere.  Does someone have an example?

0 Kudos
Message 1 of 7
(2,319 Views)

This isn't that helpful yet, but maybe this is illustrative of part of the workaround: Python Virtual Environments - Beta Forum.

 

It uses the new (as yet unreleased) LabVIEW 2021 beta Python node, which allows you to pass a path for the python executable.

 

I suspect, although I haven't tried, that if you added the necessary paths for your venv environment to your OS, and removed the paths to the system installation, that you might be able to do this... but changing between different environments would be a non-starter in that case (because you can't easily change your paths via e.g. environment variable and have them affect the running LabVIEW process - you have to restart LabVIEW).


GCentral
0 Kudos
Message 2 of 7
(2,269 Views)

Thanks I'll look into that.  Not a great workaround, but maybe a start.  If their is an NI supporter on the thread, could they go ask the presenter Kevin Flanagan if this is what he meant by workaround for completeness.

0 Kudos
Message 3 of 7
(2,234 Views)

So maybe not monitoring the forum.  If there is anyone interested I think the solution is the use a shebang (#!) but I haven't quite yet gotten it to work.

0 Kudos
Message 4 of 7
(2,197 Views)

Bump.  Anyone at NI going to follow-up up with the presenters to see what they have to say?

0 Kudos
Message 5 of 7
(2,168 Views)

did you ever find the answer to your question?

regards,
Bill
0 Kudos
Message 6 of 7
(1,543 Views)

Nope.  I had to give up due to lack of RT support, but I haven't looked in a while so maybe that changed.

0 Kudos
Message 7 of 7
(1,524 Views)