labrad/pylabrad

oauth.py is no longer python 2 compatible

aransfor opened this issue · 5 comments

at some point the oauth file switched its import from the python 2 package BaseHTTPServer to they python 3 package http.server which seems to affect servers such as the gpib server for python 2 users. We have since downgraded to an old version of pylabrad (0.95.3)

pylabrad will still work with python2.7 after the referenced change, but there are some additional dependencies that must be installed. All the dependencies are listed in requirements.txt. In particular, a backported version of the python 3 http.server library is included with the future package, so you will need to run pip install future (or, more generally, pip install -r requirements.txt to get all required dependencies). Actually, I'd be curious to know how you are using pylabrad, because if you are pip installing it from pypi, then pip should pull in all the requirements for you automatically. But if you're just checking out the source code and putting it on your python path then you'll need to install the dependencies manually.

We pip install so just doing pip install pylabrad is not sufficient I will try pip install futures

Another thing to check for is if you have some other http package on the python path. For example, the martinisgroup/servers repo has an http package (https://github.com/martinisgroup/servers/tree/master/http) so if that is on your pythonpath, then the code in oauth.py might try to import that instead of the backported http package from future, which is what you want. In a python session you can do import http and then look at http.__file__ to see which package is actually getting imported. (There's a PR to rearrange the servers repo to move everything into a labrad.servers subpackage to avoid package name collision issues like this, but it's not merged yet.)

It's great to see that someone is having the same trouble. :)

I just started to try upgrading to the latest version of pylabrad and everything else from a version that is 6-7 years old. Using Python 2.7 and running into the same trouble. The latest Data Vault 3.0.1 refuses to start with http.server error.

My solution is commenting out the 3 lines in the oauth file that are related to http.server and replacing them with BaseHTTPServer. Then the data vault can start now (although I am having much bigger issues trying to jump from old Delphi era to end of 2017).

I will try the pip requirement.txt upgrade and report back.

--Update: I just checked and confirmed that I've met all the requirement mentioned in requirement.txt but http.server still reports an error. I still have to hack the file and import BaseHTTPServer to run Data Vault.