The python ecosystem is a bit confusing with the different ways you can have "virtual environments" in which you can install packages - see
this famous xkcd comic, and the situation has not really become better since the comic came out - now you additionally have conda envrionments, and several other "solutions" trying to fix that situation...
In the end, you get one "python" interpreter for each virtual environment, i.e. when you install a package via conda, you need need to make sure that you use the
python
from the corresponding conda environment.
First, try to get tenpy installed in the terminal, where you can run the
conda install --channel=conda-forge physics-tenpy
. Try to just start a interactive
python
session from there and just try
import tenpy
(While the pacakge on conda and pip is called
physics-tenpy
due to a name-conflict with another package (see
Issue #242), within python you just need to
import python
.)
I guess that's also what's gone wrong with vscode: In vscode, press CTRL-Shift-P (on MAC ⇧⌘P, I think) to open the command palette, and choose "Python: Select interpreter". This will list different python versions you have installed - and you need to choose the one where you have installed the tenpy package.
When you called the
conda env create -f environment.yml
, this will create a new conda environment (called
tenpy
by default), so you need to activate that environment with
conda activate tenpy
in the terminal, or in VScode by selecting the corresponding python interpreter.
Reference:
conda getting started and other parts of that user guide.