kwant and Anaconda distribution

Hi all, I have a more Python related question, however since it's related with Kwant installation I hope you can help me. I have just installed the latest Kwant update (using python 3) via apt-get on Ubuntu 14.04 using the ppa. However, since I'd like to have the latest scipy, numpy matplotlib etc. packages, I also installed Anaconda 3 in my home directory: my bashrc is set with Anaconda path. I'd like to use the latest jupyter/ipython shell with kwant, but when I try to import kwant it gives me an error probably because of Python path issues. I'm not an expert with Python, so I'd like to know how I should import the kwant module which is installed system-wide. The other way could be obviously to install kwant from conda repositories but it looks like they're not updated yet to the latest version. Thank you in advance, Jessica

Hi Jessica, What error do you get exactly? Can you post the full message? Is the Python interpreter that you are using provided by Ubuntu or by Conda? If it's provided by Conda (let's say it can be launched as "conda-python"), you can try to use pip with that interpreter to build kwant from source: conda-python -m pip install kwant You might have to give some other option like --user or --target. Before running that command make sure that the non-Python build dependencies for Kwant (especially MUMPS) are present. The easiest way to do this is to run sudo apt-get build-dep kwant I hope this helps. Christoph

Hi Christoph, thank you very much for your suggestion. Indeed, my Python interpreter is that shipped with Anaconda, since the path is set to my local Anaconda installation in my home, i.e. which python /home/alfonsi/anaconda3/bin/python Of course, the other way around could be the one you suggested with pip, but still I think there should be a way to import a m,odule from a system directory where kwant is installed via ppa. Anyway, I'm going to make further inquiries into this matter in the next days. Best regards, Jessica This is what I obtained after launchin jupyter notebook and executing the first notebook cell In [1]: import matplotlib.pyplot import kwant ---------------------------------------------------------------------------ImportError Traceback (most recent call last)<ipython-input-1-52a8ee343ba6> in <module>() 1 import matplotlib.pyplot----> 2 import kwant ImportError: No module named 'kwant'

Hi Jessica, Looking at the conda (the anaconda environment management tool) documentation, it appears there is no designed way to force it to use system packages [1]. You probably can find a workaround it by setting the PYTHONPATH environment variable, but this may cause further troubles due to conflicts between different versions of numpy and python. So I really would recommend you to use pip in the conda environment. Best, Anton [1]: http://conda.pydata.org/docs/commands/conda-create.html On Tue, Dec 22, 2015 at 8:42 PM, Jessica Alfonsi <jessica.alfonsi@gmail.com> wrote:
Hi Christoph, thank you very much for your suggestion. Indeed, my Python interpreter is that shipped with Anaconda, since the path is set to my local Anaconda installation in my home, i.e. which python /home/alfonsi/anaconda3/bin/python Of course, the other way around could be the one you suggested with pip, but still I think there should be a way to import a m,odule from a system directory where kwant is installed via ppa. Anyway, I'm going to make further inquiries into this matter in the next days.
Best regards, Jessica
This is what I obtained after launchin jupyter notebook and executing the first notebook cell
In [1]:
import matplotlib.pyplot
import kwant
--------------------------------------------------------------------------- ImportError Traceback (most recent call last) <ipython-input-1-52a8ee343ba6> in <module>() 1 import matplotlib.pyplot ----> 2 import kwant
ImportError: No module named 'kwant'

Thank you very much Anton for making this point clear. So just a suggestion for the future, would it be possible to provide also official conda binaries for kwant please ? Best, Jessica 2015-12-23 11:34 GMT+01:00 Anton Akhmerov <anton.akhmerov+kd@gmail.com>:
Hi Jessica,
Looking at the conda (the anaconda environment management tool) documentation, it appears there is no designed way to force it to use system packages [1]. You probably can find a workaround it by setting the PYTHONPATH environment variable, but this may cause further troubles due to conflicts between different versions of numpy and python. So I really would recommend you to use pip in the conda environment.
Best, Anton
[1]: http://conda.pydata.org/docs/commands/conda-create.html
On Tue, Dec 22, 2015 at 8:42 PM, Jessica Alfonsi <jessica.alfonsi@gmail.com> wrote:
Hi Christoph, thank you very much for your suggestion. Indeed, my Python interpreter is that shipped with Anaconda, since the path is set to my local Anaconda installation in my home, i.e. which python /home/alfonsi/anaconda3/bin/python Of course, the other way around could be the one you suggested with pip, but still I think there should be a way to import a m,odule from a system directory where kwant is installed via ppa. Anyway, I'm going to make further inquiries into this matter in the next days.
Best regards, Jessica
This is what I obtained after launchin jupyter notebook and executing the first notebook cell
In [1]:
import matplotlib.pyplot
import kwant
---------------------------------------------------------------------------
ImportError Traceback (most recent call last) <ipython-input-1-52a8ee343ba6> in <module>() 1 import matplotlib.pyplot ----> 2 import kwant
ImportError: No module named 'kwant'

Hi Jessica, Yes, we plan to also provide Kwant packages in conda eventually. We might wait with this until next versions of Kwant, when we simplify Kwant dependencies. If you, (or anyone else) wants to figure it out now, we would welcome this effort. The hardest part right now is interfacing the MUMPS library, crucial for Kwant performance. Best, Anton On Wed, Dec 23, 2015 at 1:57 PM, Jessica Alfonsi <jessica.alfonsi@gmail.com> wrote:
Thank you very much Anton for making this point clear. So just a suggestion for the future, would it be possible to provide also official conda binaries for kwant please ?
Best, Jessica
2015-12-23 11:34 GMT+01:00 Anton Akhmerov <anton.akhmerov+kd@gmail.com>:
Hi Jessica,
Looking at the conda (the anaconda environment management tool) documentation, it appears there is no designed way to force it to use system packages [1]. You probably can find a workaround it by setting the PYTHONPATH environment variable, but this may cause further troubles due to conflicts between different versions of numpy and python. So I really would recommend you to use pip in the conda environment.
Best, Anton
[1]: http://conda.pydata.org/docs/commands/conda-create.html
On Tue, Dec 22, 2015 at 8:42 PM, Jessica Alfonsi <jessica.alfonsi@gmail.com> wrote:
Hi Christoph, thank you very much for your suggestion. Indeed, my Python interpreter is that shipped with Anaconda, since the path is set to my local Anaconda installation in my home, i.e. which python /home/alfonsi/anaconda3/bin/python Of course, the other way around could be the one you suggested with pip, but still I think there should be a way to import a m,odule from a system directory where kwant is installed via ppa. Anyway, I'm going to make further inquiries into this matter in the next days.
Best regards, Jessica
This is what I obtained after launchin jupyter notebook and executing the first notebook cell
In [1]:
import matplotlib.pyplot
import kwant
--------------------------------------------------------------------------- ImportError Traceback (most recent call last) <ipython-input-1-52a8ee343ba6> in <module>() 1 import matplotlib.pyplot ----> 2 import kwant
ImportError: No module named 'kwant'

Anton Akhmerov wrote:
You probably can find a workaround it by setting the PYTHONPATH environment variable, but this may cause further troubles due to conflicts between different versions of numpy and python.
I do not think that there would be any conflicts. I believe that the only question is whether the conda Python interpreter will accept the compiled extensions that are part of Kwant. I think there’s a good chance that this will work if the major version of the interpreters matches (e.g. 3.4). The directory added to PYTHONPATH should only contain Kwant (and Tinyarray) of course.

In the end I've chosen to keep anaconda and system environments separated, so it's a lot easier and faster installing with (Anaconda) pip as Christoph suggested at the beginning of this discussion. The point is that the right PYTHONPATH to be set is /usr/lib/python3/dist-packages/ (i.e. without kwant) but this gives me conflicts with numpy and other packages previously installed with apt-get. So it's better to keep system-wide and Anaconda packages in their different environments. 2015-12-24 9:22 GMT+01:00 Christoph Groth <christoph.groth@cea.fr>:
Anton Akhmerov wrote:
You probably can find a workaround it by setting the PYTHONPATH
environment variable, but this may cause further troubles due to conflicts between different versions of numpy and python.
I do not think that there would be any conflicts. I believe that the only question is whether the conda Python interpreter will accept the compiled extensions that are part of Kwant. I think there’s a good chance that this will work if the major version of the interpreters matches (e.g. 3.4).
The directory added to PYTHONPATH should only contain Kwant (and Tinyarray) of course.
participants (4)
-
Anton Akhmerov
-
Anton Akhmerov
-
Christoph Groth
-
Jessica Alfonsi