Python 3.12 and Qiskit

I’m installing Python 3.12 and that much worked as expected.

At the COMMAND prompt I typed pip install qiski and that appeared to work.

When I go into the IDE and paste the below code it can’t find qiskit.

What am i missing

from qiskit.circuit.library import HGate
 
qc = QuantumCircuit(1)
qc.append(
    HGate(),  # New HGate instruction
    [0]       # Apply to qubit 0
)
qc.draw("mpl")

It may be possible that the pip used in COMMAND prompt is not installing in the same place, as the place your IDE is looking for packages.
Your need to provide more details here: what IDE are your using? what system are you using?

1 Like

I’m using Pycharm

And thanks Alex

Yes, we see this problem constantly. Pycharm creates a virtual environment for the project, and expects to manage that environment for you. You should use Pycharm’s interface in order to install third-party libraries like Qiskit into that environment.

1 Like

Since I’m new at Pycharm and Python…How do I Pycharm’s interface in order to install third-party libraries like Qiskit into that environment.

Regards,

Steve Beaver

steve@stevebeaver.com

Office : 806-368-3859

Cell : 806-300-9481

No man is a true believer unless he desires for his brother that, what he desires for himself.

Or is there a better ? less quirky IDE that PyCharm?

Regards,

Steve Beaver

steve@stevebeaver.com

Office : 806-368-3859

Cell : 806-300-9481

No man is a true believer unless he desires for his brother that, what he desires for himself.

Hi !

You’ll find several ways to manage Python packages in PyCharm in the online documentation:

Another (more convenient IMO) way to manage Python packages is to use the terminal emulator directly in PyCharm (see Terminal emulator | PyCharm Documentation).
To put it simply, any command you type there (pip install ... for example) will only affect the virtual environment associated to your project. When running a script from PyCharm’s terminal emulator, or from the graphical interface, your project’s environment will be used.

I cannot suggest alternative IDEs, but PyCharm is for sure quite heavy machinery. It’s really well-suited for large projects, or integration with version-control systems, but might not be the best option for beginners.

2 Likes

I am trying to learn quantam computing. I have installed Python on MAC. While trying to install qiskit using pip , Iam getting the below error

(cwq) APLXXXXXXXX:~ RTEWV$ pip install qiskit
Looking in indexes: https://repo.usaa.com/artifactory/api/pypi/pypi/simple
ERROR: Could not find a version that satisfies the requirement qiskit

The version of python and pip
(cwq) APLXXXXXXXX:~ RTEWV$ python --version
Python 3.12.4
(cwq) APLXXXXXXXX:
~ RTEWV$ pip --version
pip 24.0 from /Users/RTEWV/.conda/envs/cwq/lib/python3.12/site-packages/pip (python 3.12)

I am not able to install the qiskit by specifying the version as well. I am not clear from where PIP pick up the qiskit version. Any help on this will be appreciated.

Thanks
RJ