2
$\begingroup$

I'm trying to get started with Qiskit but the installation process has been horrendous and the official instructions are unusable. The latest python doesnt work with the install instructions at: https://qiskit.org/documentation/install.html (qiskit devs lurking here: can you please update the instructions on the official website or atleast add links to fixes for known issues for novices like me?)

qiskit-aer didnt install until I deprecated python to 3.8 for the qiskit env via: conda create -n name_of_my_env python=3.8

Then, the jupyter notebook didn't recognize the new environment until I tried: python -m ipykernel install --user --name myenv --display-name "Python (myenv)"

Now, the jupyter notebook in the qiskit env wouldnt connect to the kernel and I'm not sure what to do. The error message I get on the jupyter nb is: A connection to the notebook server could not be established. The notebook will continue trying to reconnect. Check your network connection or notebook server configuration.

I'm not a software engineer and I'm getting tired of poking randomly on the internet for hours with error messages I don't understand. Suggestions on how I can get jupyter nb in qiskit env to connect to the kernel? Should I expect more such software nuisance with qiskit?

Thanks!

$\endgroup$
8
  • 1
    $\begingroup$ Hello, sorry to hear about all these errors. Could you tell us more about how exactly you got this exactly? First on what system you run this (Windows, macOS, Ubuntu), and the exact message with the commands that got you there? Maybe if I can better understand how you got to the error I can see how to fix it! In the meantime if you want to use Qiskit right now you can do it via the online platform quantum-computing.ibm.com by creating an account and then you can create notebooks via the quantum lab! $\endgroup$ – Lena Jan 6 at 8:25
  • 3
    $\begingroup$ qiskit is not supported yet with python 3.9. The Qiskit metapackage (pypi.org/project/qiskit) gives you the supported version of python. Concerning your Kernel connection problem, as Lena said it would help having the error message you get ... $\endgroup$ – Patrick Mensac Jan 6 at 13:39
  • 1
    $\begingroup$ Qiskit is really awesome in my opinion but yeah.... installing it can be a pain. The Quantum Lab that Lena mentioned was a great workaround for me for awhile too. I wish there is a way to get allocated memory in each of the notebook though. @PatrickMensac and Lena: Is there a way to combine the entire allocated 32 GB memory to a single notebook. I believe that each notebook has an allocated memory of 8GB and each user has 32GB in total. Is that right? $\endgroup$ – KAJ226 Jan 6 at 15:34
  • 1
    $\begingroup$ @KAJ226 from my understandgin, 8GB is tihe total memory allocated to run all of your notebooks in Quantum Experience. Opening and executing multiples notebooks will increase your memory consumed and this value is reflected in the banner of all of your notebooks. I'm not aware of a 32GB of memory vailable for each user :-) $\endgroup$ – Patrick Mensac Jan 6 at 16:26
  • 1
    $\begingroup$ Thanks, everyone. I have reinstalled anaconda and qiskit from scratch via: conda create -n qiskit python=3.8, conda install jupyter, conda activate qiskit, pip install qiskit. Do I have to install jupyter within the new qiskit environment as well? How do I add the qiskit environment to the Jupyter notebook? I'm using a windows machine. Should I add the new environment to jupyter nb manually via ipykernel like in the OP? $\endgroup$ – user14392 Jan 6 at 21:20
2
$\begingroup$

Although this is already late, still I am writing an answer, because I was too stuck for hours early at the same problem.

  1. I don't think qiskit is not yet supported in python3.9 because because for 3.9 there's no qiskit-aer build available.

  2. Regarding installing it with python 3.8 following steps should be sufficient:

1. conda create -n <new env> python=3.8
2. conda activate <new env>
3.a conda install notebook ipykernel
3.b python -m ipykernel install --user --name=<new env>
3.c jupyter kernelspec list (new env should be available in the list)
4. python -m pip install --upgrade qiskit
// no need to have jupyter in the corresponding env
5. Open jupyter from any environment or even outside conda (but while opening jupyter you have to be in the environment which has the jupyter installed in it)
6. Open a notebook using <new env> kernel
7. import qiskit as q

3 and 4th steps to be executed while new env is activated only.

Also

For jupyter notebook, the following python package is useful for managing which python kernel / anaconda environment to run a notebook with:

pip install environment_kernels (you have to be in the environment which has the jupyter installed in it)

If you open the jupyter from this environment, you can change kernel in two ways after opening jupyter:

  1. Kernel options to start a new notebook
  2. In the kernel > change kernel dropdown for an existing notebook.
$\endgroup$
1
  • 1
    $\begingroup$ +1 and welcome to the community! Thank you for your contribution and we hope to see a lot more of you here!!! $\endgroup$ – user1271772 Jan 25 at 23:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.