problem about installing tenpy

How do I use this algorithm? What does that parameter do?
Post Reply
jiyashxi
Posts: 2
Joined: 30 Sep 2024, 04:17

problem about installing tenpy

Post by jiyashxi »

Hi,

I am very new to TeNPy package. When I try to install this package on mac, I first use

Code: Select all

conda install --channel=conda-forge physics-tenpy
and it succeeded. But when I tried to use

Code: Select all

import tenpy 
on vscode, it says

Code: Select all

no module named tenpy
. Then I checked the list of packages and found one named physics-tenpy. But when I try to

Code: Select all

import physics-tenpy
, I was told 'invalid syntax'. How to solve this problem?

Also, I then try to create a new environment using the environment.yml file in the link https://tenpy.readthedocs.io/en/latest/install/pip.html by

Code: Select all

conda env create -f environment.yml
, I got

Code: Select all

ResolvePackageNotFound: 
  - libblas[build=*mkl]
  - mkl
  - mkl-devel
How so solve it? What is the correct way to run tenpy on my mac? Thanks a lot.
User avatar
Johannes
Site Admin
Posts: 456
Joined: 21 Jul 2018, 12:52
Location: TU Munich

Re: problem about installing tenpy

Post by Johannes »

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.
jiyashxi
Posts: 2
Joined: 30 Sep 2024, 04:17

Re: problem about installing tenpy

Post by jiyashxi »

Hi,

This solved my problem! The interpreter used in my vscode is different from what I installed tenpy. Thanks a lot!
Post Reply