I’m Olivia, I’m a quantum computing researcher at TRIUMF in Vancouver, Canada. I work with nuclear and high-energy physicists on finding problems in their domains that might benefit from quantum computing. I do a lot of programming for my own research projects in quantum circuit synthesis/optimization and tomography. I also love writing, working with students, and teaching - especially teaching scientists from other fields about how quantum computing works.
I recently got started with the QDK to contribute to development of a new library for Q# about quantum RAM. However, I ran into a few issues during the installation process. Turns out they were easily fixable, but I had to slightly tweak the commands from the installation guide and the sequence of tweaks is not written in full anywhere. One of our goals for developing the qRAM library is to fully document the process, to help others develop libraries of their own. So here I’ve compiled everything together for the next person who might run into similar issues.
My machine is running Ubuntu 19.10. I have no prior experience with anything .NET, so I started installation from scratch. I followed these installation instructions for getting set up to develop with Q# in conjunction with Python and Jupyter notebooks.
The first step was pretty straightforward:
I already had Python installed on my machine with Anaconda. I was able to install the .NET Core SDK 3.1 following its Linux installation instructions page. At the time of writing, the instructions are to first add the product key:
$ wget https://packages.microsoft.com/config/ubuntu/19.10/packages-microsoft-prod.deb -O packages-microsoft-prod.deb $ sudo dpkg -i packages-microsoft-prod.deb
Then, actually install the package by running:
$ sudo apt-get update $ sudo apt-get install apt-transport-https $ sudo apt-get update $ sudo apt-get install dotnet-sdk-3.1
Enter Python and Q#.
The first thing I did was make a new Anaconda environment. Then, I switched over to it before installing the qsharp package.
$ conda create --name qdk python=3.8 $ conda activate qdk $ python -m pip install qsharp
-m flag is telling python to use the
pip module from the path stored in Python’s
sys.path. This ensures that
qsharp gets installed on the version of Python within our active environment rather than the “global” Python. You can see what this is set to by running
which python, or checking within Python itself. If you’re in the conda environment, you’ll see that it points to the Python of your environment and not just something like
This is where I started running into trouble…
The first command ran with no issues, but my terminal yelled at me after the second:
We know that it can’t be one of the first two reasons - the spelling is fine, and
dotnet-iqsharp certainly exists having run the first command just fine. The issue then must be with the path. It turns out that when installing the .NET Core on Linux, it is a common problem that the tools don’t get added automatically to your path. The way to solve this, as per the link above, is by adding them to the path explicitly:
$ echo "export PATH=\"\$PATH:\$HOME/.dotnet/tools\"" >> ~/.zshrc
zsh so I am sending the output to
~/.zshrc. If you use a different shell such as
bash you’ll need to replace
~/.zshrc with whatever the name of your configuration file is (probably
Now that the
dotnet command knows where to find our tools, we should be golden. However, this is what happened next…
Even when I ran with
sudo, I ended up with the same error as before! Let’s look at that error message again:
➜ dotnet iqsharp install [Errno 13] Permission denied: '/usr/local/share/jupyter' Perhaps you want to install with `sudo` or `--user`?
I noticed that the path here is wrong - it is trying to use the
jupyter command from
/usr/local/share, but it should be using the one from the
qdk conda environment:
The solution then is to use the
With that, you should be able to run
import qsharp in Python, and you’re ready to go!