How do I install U3 software on a Linux Python Virtual Environment? | LabJack
 

How do I install U3 software on a Linux Python Virtual Environment?

6 posts / 0 new
Last post
ullix
ullix's picture
How do I install U3 software on a Linux Python Virtual Environment?

I use Ubuntu 16.04 which has Python 3.5 and installed LabJackPython 2.0.4. 'pip list' does show it, and my u3  runs as it should.

But for development purposes I also need to have higher Py versions available, and while one can install them in parallel, it results in a huge mess once you begin to add modules by pip. So I am using a Python Virtual environment. (I put a HOWTO for this here: https://sourceforge.net/projects/geigerlog/files/Articles/HOWTO%20-%20Using%20Python%20in%20a%20virtual%20Environment%20on%20Linux-v1.0.pdf/download

Now I can also run Py3.6, Py3.7, Py3.8, Py3.9, Py3.10, and run them even simultaneously, but there is no LabJack!

How do I get the Labjack modules into all my Python virtual environments? Starting the setup from each of these venvs did not help.

LabJack Support
labjack support's picture
The issue may be that you are

The issue may be that you are not installing the package to Python in your virtual environment. Is your virtual environment active when you try the install? If you run which python on the command line before doing the install does that point to your global python install (usually /usr/local/bin/python or /usr/bin/python)?

You can explicitly specify the path to the python version you want to install the package under, so say your environment is called env-bar and python in your virtual environment is under /home/foo/env-bar/bin/python you could try doing the install by navigating to the LabJackPython install directory and running:

sudo /home/foo/env-bar/bin/python setup.py install

ullix
ullix's picture
I am afraid this is in

I am afraid this is in conflict with the way the virtual environment is handled.

In my system 'python' points to Python2.7, 'python3' to Python3.5. These are the original installations, and they reside at /usr/bin/python(3). However, all other ones also are in the same folder at /usr/bin/python3.(6,7,8,9,10). But in the virtualization those will never be called directly. Instead you have to make a folder of your choice (like vgl36) and create the virt env with 'python3.6 -m venv vgl36'. This creates a copy of Py3.6. Then you activate the venv with 'source vgl36/bin/activate', which changes your prompt to '(vgl36) [email protected]:~$'. Now 'which python' yields '/home/user/vgl36/bin/python'.   This python version is symlinked to /usr/bin/python3.6. But all pipped in modules reside in a subfolder to vgl36! And this is where LabJack-stuff should go too.   I am afraid your command would bypass this virt env and likely ruin the installation.      

 

LabJack Support
labjack support's picture
Yes, I would expect my

Yes, I would expect my initial suggestion to fail since you are using a symbolic link to your system Python. Sorry about that. There may be a way to modify your python path to get the setup script install working with the flag --prefix, but that is probably not ideal.

We do have the newest module on PyPI and therefore available via pip install. With your virtual environment active, try a call such as:

python3.6 -m pip install LabJackPython

LabJack Support
labjack support's picture
I updated our LabJackPython

I updated our LabJackPython page to better document the pip installation method:

https://labjack.com/support/software/examples/ud/labjackpython

ullix
ullix's picture
Ooooooh, you have it on PyPi!

Ooooooh, you have it on PyPi! Why didn't you say so in the beginning? 

Inspecting the site https://pypi.org/project/LabJackPython/#history it looks like you have it there for years. Nothing was mentioned on your site, were you trying to hide it?  What a shame; instead detailed setup  instructions were given. So I didn't even bother to check PyPi. Good, this has changed!

With PyPi available, installation to all virtual environments is as easy as it can possibly be. Using the pip features, I can even install any specific version I may want.

From my struggle with handling multiple Python versions simultaneaously, I do recommend to always use this long command:

python -m pip install -U LabJackPython

(-U for updating in case an older version is already installed) instead of the short version starting with pip.

And when handling more than one Py version, get used to 'venv'!

All done now, thanks!