Python compatibility

Dear all,

I have installed haddock2.4-2020-06 on a Mac (version 10.12.6), following the instructions from here: https://www.bonvinlab.org/education/HADDOCK-local-tutorial/
The computer uses Python 3:
bash-3.2$ which python
/anaconda3/bin/python

The Python scripts are all written in Python 2. I adapted them accordingly.
However, I am running into a more difficult issue when the script haddock/Haddock/ThirdParty/DictWithDefault.py
tries to import UserDict (line 3).
After some research, I found out that the module UserDict has been removed and cannot be found in Python 3.
Any suggestions?

There are many more differences with python3…

The 2.4 version does required Python2.7 as indicated in the instructions.

We will probably release early 2021 a Python3.8 version (will be 2.5).

Hi Olivier,

Since you’re using Anaconda, the best would be to create an environment for haddock with Python 2.7. We’re doing the same conversion for haddock2.5 and it’s not trivial.

conda create --name haddock python=2.7

Should get you started.

Cheers,

João

A sexta, 4/09/2020, 10:48, Olivier Bignucolo via BioExcel <bioexcel@discoursemail.com> escreveu:

Dear João,
Thanks a lot for the hint. I am just afraid that this command would overwrite the Python 3 version, which I don’t want to loose.
If not, should the command that you recommand be entered from within the software/haddock folder or anywhere else?

Olivier

Hi Olivier,

When you create Anaconda environments, you isolate an instalation of python and whatever you install there doesn’t impact other environments. If you never create environments, you install and run things from the base environment (the default). This is not ideal because as you mentioned, you risk changing python/library versions and creating conflicts.

I wrote a small tutorial a couple of months ago that might be helpful: https://joaorodrigues.github.io/intro-to-conda/

In short, when you do “conda activate xyz” you switch to using the python installed in that environment and have access only to libraries installed therein. If you then do “conda deactivate” or “conda activate xyz2”, you leave that environment (and/or move to xyz2).

Let us know if this is unclear and I’d be happy to help you troubleshoot.

Cheers,

João

You can type these commands anywhere, they’re not folder specific either!

A sábado, 5/09/2020, 11:32, Olivier Bignucolo via BioExcel <bioexcel@discoursemail.com> escreveu:

Dear Joao,

Congratulations for the tutorial about environments using conda. It is very well written, so that I could follow it without problem. I will process to the next steps soon.
Thanks again for your prompt answers.

Olivier