rigetti / reference-qvm

A reference implementation for a quantum virtual machine in Python
Apache License 2.0
46 stars 20 forks source link

pyquil.quilbase in qvm_wavefunction.py cannot find Instr module #14

Closed astrophys closed 6 years ago

astrophys commented 6 years ago

I recently installed referenceqvm via pip for python 3.6.3. When I try to run the example on your website, I get the following error:

>>> import referenceqvm.api as api
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/gpfs0/home/gdhpcgroup/user/local/pip-installs/python-3.6.3/lib/python3.6/site-packages/referenceqvm/api.py", line 5, in <module>
    from referenceqvm.qvm_wavefunction import QVM_Wavefunction
  File "/gpfs0/home/gdhpcgroup/user/local/pip-installs/python-3.6.3/lib/python3.6/site-packages/referenceqvm/qvm_wavefunction.py", line 45, in <module>
    from pyquil.quilbase import (Instr,
ImportError: cannot import name 'Instr'

It seems that the ‘Instr’ does not exist. Advice?

vtomole commented 6 years ago

Seems like the reference-qvm on pip is not up to date. Install the reference-qvm from source by cloning this repository, cd into it, and running

pip install -r requirements.txt -e .

astrophys commented 6 years ago

Hmm.. I'm using a globally installed version of python on a computing cluster. It appears that reference-qvm (through dependancies) requires packaging 17.1, but my python install has v16.8. The pip process fails because it tries to uninstall the globally installed version of packaging, which is owned by root. E.g.

pip install --prefix ~/local/pip-installs/python-3.6.3/ -r requirements.txt -e .
.
.
.
.
  Found existing installation: packaging 16.8
    Uninstalling packaging-16.8:
Exception:
Traceback (most recent call last):
  File "/gpfs0/export/opt/anaconda3-5.0.1/lib/python3.6/shutil.py", line 544, in move
    os.rename(src, real_dst)
OSError: [Errno 18] Invalid cross-device link: '/gpfs0/export/opt/anaconda3-5.0.1/lib/python3.6/site-packages/packaging' -> '/tmp/pip-61h9k522-uninstall/gpfs0/export/opt/anaconda3-5.0.1/lib/python3.6/site-packages/packaging'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/gpfs0/export/opt/anaconda3-5.0.1/lib/python3.6/site-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/gpfs0/export/opt/anaconda3-5.0.1/lib/python3.6/site-packages/pip/commands/install.py", line 342, in run
    prefix=options.prefix_path,
  File "/gpfs0/export/opt/anaconda3-5.0.1/lib/python3.6/site-packages/pip/req/req_set.py", line 778, in install
    requirement.uninstall(auto_confirm=True)
  File "/gpfs0/export/opt/anaconda3-5.0.1/lib/python3.6/site-packages/pip/req/req_install.py", line 754, in uninst
all
    paths_to_remove.remove(auto_confirm)
  File "/gpfs0/export/opt/anaconda3-5.0.1/lib/python3.6/site-packages/pip/req/req_uninstall.py", line 115, in remo
ve
    renames(path, new_path)
  File "/gpfs0/export/opt/anaconda3-5.0.1/lib/python3.6/site-packages/pip/utils/__init__.py", line 267, in renames
    shutil.move(old, new)
  File "/gpfs0/export/opt/anaconda3-5.0.1/lib/python3.6/shutil.py", line 556, in move
    rmtree(src)
  File "/gpfs0/export/opt/anaconda3-5.0.1/lib/python3.6/shutil.py", line 480, in rmtree
    _rmtree_safe_fd(fd, path, onerror)
  File "/gpfs0/export/opt/anaconda3-5.0.1/lib/python3.6/shutil.py", line 438, in _rmtree_safe_fd
    onerror(os.unlink, fullname, sys.exc_info())
  File "/gpfs0/export/opt/anaconda3-5.0.1/lib/python3.6/shutil.py", line 436, in _rmtree_safe_fd
    os.unlink(name, dir_fd=topfd)
PermissionError: [Errno 13] Permission denied: 'requirements.py'
vtomole commented 6 years ago

Try updating to packaging 17.1: https://anaconda.org/conda-forge/packaging

ncrubin commented 6 years ago

@astrophys not sure when that particular package was added as a dep. I can hunt around to look for where it is referenced. In the meantime you can probably download anaconda (which installs a non-rooted version of python in your local directory). As long as your bashrc or bash_profile is pointing towards the local python you can updated packages at will.

I will continue to hunt around for when this package is used.

astrophys commented 6 years ago

@vtomole going with a fresh local install of anaconda python 3.6.5 and the installing directly from the git hub repo (as suggested above), seemed to provide a work around solution. Thanks.

vtomole commented 6 years ago

@astrophys You are welcome!