qiskit-community/qiskit-qec

Installing in Jupyter (lab) notebook or IBM Quantum Lab

Closed this issue · 2 comments

What is the expected enhancement?

The install guide does not provide an installation method for installing in a Jupyter(lab) notebook (including IBM Quantum Lab) when installing from the git repo and not via PyPI. This should be added. Since installing from a git repo directly the path for imports needs to be updated with the location that pip installs the package.

The current procedure that seems to work is:

!get clone https://github.com/qiskit-community/qiskit-qec
pip install -e qiskit-qec/.

If the pip install does not work (i.e. cannot find pip) then use instead

!pip install -e qiskit-qec/.

Then find out where pip installed the package. This can be achieved as follows:

pip show qiskit_qec

An example output is:

Name: qiskit-qec
Version: 0.0.1
Summary: Qiskit quantum error correcting (QEC) package
Home-page: https://github.com/Qiskit/qiskit-qec
Author: Qiskit Development Team
Author-email: hello@qiskit.org
License: Apache 2.0
Location: /home/jovyan/qiskit-qec
Requires: qiskit-terra, qiskit-aer, PyMatching, retworkx, networkx, sympy, numpy
Required-by: 
Note: you may need to restart the kernel to use updated packages.

Now add the location path to the path that import uses:

sys.path.append('/path/to/module')

So for our example this would be:

sys.path.append('/home/jovyan/qiskit-qec')

Issues:

You may get a warning. So say you use the import:

from qiskit_qec.operators.pauli import Pauli

Then the waning is

<frozen importlib._bootstrap>:219: RuntimeWarning: scipy._lib.messagestream.MessageStream size changed, may indicate binary incompatibility. Expected 56 from C header, got 64 from PyObject

But everything seems to work but we should see what the issue is. May be due to different C/C++ type sizes between machines and OSs.

I think it is fixed in #232

Now you can install package using

pip install --no-cache --upgrade git+https://github.com/qiskit-community/qiskit-qec.git

screencapture-lab-quantum-computing-ibm-user-60e880fb464d23a2c33d4201-lab-workspaces-auto-T-tree-Untitled3-ipynb-2022-07-07-10_39_05

Yes. This makes pip install in the standard location. I like this better. Should include in installation notes.