qiskit-metapackage
qiskit-metapackage copied to clipboard
Weird behavior installing qiskit with "pip -t"
Informations
- Qiskit version: 0.36.2
- Python version: 3.10.2
- Operating system: Windows 10 21H2 (19044.1766) and Ubuntu 22.04 LTS
What is the current behavior?
When I install qiskit using this command line:
Windows --> path/to/bin/python.exe -m pip install qiskit -t path/to/custom/folder
Ubuntu --> sudo path/to/bin/python3.10 -m pip install -t path/to/custom/folder
The installation seems to go through all the steps as intended. No error message shows up.
However, the qiskit folder located at path/to/custom/folder/qiskit is almost empty. The folder only contains one file named __init__.pxd.
It is then impossible to use qiskit (no modules found on import).
Steps to reproduce the problem
- Create a new conda env:
conda create -n "test_qiskit_install" python=3.10 - Run:
conda activate test_qiskit_install - Run:
pip install wheel - Run:
pip install qiskit --upgrade --no-cache-dir -t "path/to/custom/folder"(for me it is"C:\Users\felix\miniconda3\envs\test_qiskit_install\Lib\site-packages"
What is the expected behavior?
The expected behavior is to have qiskit installed properly (with all modules in the qiskit folder).
Suggested solutions
This looks like a rather unusual mixture of different packaging solutions, and extra complication. Qiskit is installed as a namespace package, and I suspect that supplying the -U option in conjunction with -t causes this to fail. The solution is simply to not use either option (or just -U, if you need to upgrade, and not to suppress the warning that arose from qiskit install -t qiskit). Running pip install qiskit should work just fine, even within a conda environment.
Ok, I see. When using an anaconda environment, it is ok. But when I use a local python distribution (like in Blender which comes with its own python distribution), I would need to precise the site-packages folder to prevent installing it in an unintended location. Do you know another way to precise where to install qiskit using pip if the "-t" can't work?
You generally do not need the -t option to pip, if you make sure you're using the pip from the distribution or virtual environment you're trying to install into. -t also seems to be a more low-level/specific form of --prefix, if you're intending to use a particular Python distribution - you probably want --prefix, if it's necessary to use anything.
pip install -t <dir> was never intended for use with namespace packages, so there's not really anything we can do on the Qiskit side for this. You can see some more discussion here: pypa/pip#10110.
closing as not planned.