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