Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RecursionError: maximum recursion depth exceeded while getting the repr of an object #260

Closed
ivnsch opened this issue Dec 1, 2024 · 12 comments

Comments

@ivnsch
Copy link

ivnsch commented Dec 1, 2024

Hi, I just installed meeko from conda-forge and am following the basic docking for vina tutorial https://meeko.readthedocs.io/en/release/tutorial1.html#for-autodock-vina

pdb_file="Meeko/example/tutorial1/input_files/1iep_protein.pdb"
mk_prepare_receptor.py --read_pdb $pdb_file -o rec_1iep -p

and I get

  File "<path>/miniconda3/envs/vina/bin/mk_prepare_receptor.py", line 7, in <module>
    from meeko.cli.mk_prepare_receptor import main
  File "<path>/miniconda3/envs/vina/lib/python3.11/site-packages/meeko/__init__.py", line 10, in <module>
# ... 
RecursionError: maximum recursion depth exceeded while getting the repr of an object

What's wrong? thanks!

@rwxayheee
Copy link
Contributor

Can confirm this problem may be a result of circular import. When installed via conda, the generated script is

#!/bin/sh
'''exec' /opt/homebrew/anaconda3/envs/meeko_tutorial/bin/python "$0" "$@"
' '''
# -*- coding: utf-8 -*-
import re
import sys
from meeko.cli.mk_prepare_receptor import main
if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
    sys.exit(main())

This problem is not observed with some other package managers like micromamba. As a walkaround for the time being, you could install meeko via pip or micromamba.

We should fix this; we might want to rename the console scripts, or devert the entry points.

@rwxayheee
Copy link
Contributor

rwxayheee commented Dec 1, 2024

Hi @ivnsch
Thanks again for reporting this. I opened a PR (#261) but need to talk to other lab members about it. We will need to upload the updated package and it might take a little longer. While we're working on this, there are a few walkaround options:

@diogomart
Copy link
Contributor

I can't reproduce on linux. @rwxayheee did you observe the recursion error?

@rwxayheee
Copy link
Contributor

Hi @diogomart! Yes, I can reproduce this when installed via conda on Mac.

@diogomart
Copy link
Contributor

Do you know where the circular import happens?

@rwxayheee
Copy link
Contributor

rwxayheee commented Dec 2, 2024 via email

@diogomart
Copy link
Contributor

I can't reproduce on a Mac either. From the code I don't see a path for recursion. We should meet and figure out where it is happening, I'm afraid it might be something weird like a conflicting installation of an older meeko where we missed an if __name__ == "__main__" guard.

@rwxayheee
Copy link
Contributor

rwxayheee commented Dec 2, 2024 via email

@rwxayheee
Copy link
Contributor

rwxayheee commented Dec 3, 2024

Hello @ivnsch

I am reaching out to ask for your assistance in reproducing this issue. When I wrote the first reply to you, I could reproduce this but now I couldn't reproduce the exact issue. I'm afraid that #261 may be unnecessary and is not the right way to address this issue. Could you please let us know, if a startover from a new environment solve the issue?

When updating or reinstalling a package, some old files might not be removed (renamed) properly, causing unexpected behaviors. I have encountered, and could still produce some other importlib-related issues if I attempted to downgrade or upgrade Meeko with conda in the same environment. I think the reason is that the entry point is not properly updated, while the package body is changing with the version.

If this is the case, start over with a new environment and reinstall the required packages should always work. **If so, I will close #261 as unnecessary. ** Before, I was thinking that the problem was literally circular import but now I think it's not.

If this is a persistent issue even with a new install in a new environment, could you please provide:

  • Configuration of current environment
    Could you please share with us the output file of pip freeze > requirements.txt?

  • Content of the generated script "/miniconda3/envs/vina/bin/mk_prepare_receptor.py"

  • Did you possibly install meeko (more than one times) with multiple package managers?
    I encountered some other importlib-related issues when I have attemped to install multiple Meeko in the same environment. See below for how I found out about it. You can use similar commands to check:

(meeko_tutorial_py39) amyhe@Amys-MBP Meeko % conda list meeko
# packages in environment at /Users/amyhe/miniconda3/envs/meeko_tutorial_py39:
#
# Name                    Version                   Build  Channel
meeko                     0.5.1                     dev_0    <develop>
(meeko_tutorial_py39) amyhe@Amys-MBP Meeko % micromamba list | grep meeko
List of packages in environment: "/Users/amyhe/miniconda3/envs/meeko_tutorial_py39"
  meeko                      0.6.0        pyhd8ed1ab_1          conda-forge
(meeko_tutorial_py39) amyhe@Amys-MBP Meeko % pip list | grep meeko
meeko               0.6.0
(meeko_tutorial_py39) amyhe@Amys-MBP Meeko % 

Either way, start over would be the best way to resolve the issue. Please let us know how it goes, and we're more than willing to help ^^

@ivnsch
Copy link
Author

ivnsch commented Dec 5, 2024

I don't remember what I did to get this working before, but after removing and re-adding the environment (as instructed in https://autodock-vina.readthedocs.io/en/latest/installation.html#), I get the error below installing vina (to get mk_prepare_receptor.py). I tried passing python=3 as per instructions which uses 3.13, as well as 3.12 and 3.11.

I stopped working on this (unrelated reasons) so there's no urgency from my side, but can continue debugging if it helps.

$ python -m pip install vina
Collecting vina
  Using cached vina-1.2.5.tar.gz (89 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: numpy>=1.18 in /<path>/miniconda3/envs/vina/lib/python3.13t/site-packages (from vina) (2.1.3)
Building wheels for collected packages: vina
  Building wheel for vina (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Building wheel for vina (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [119 lines of output]
      fatal: not a git repository (or any of the parent directories): .git
      Version found 1.2.5 (from __init__.py)
      running bdist_wheel
      running build
      running build_ext
      Boost library location automatically determined in this conda environment.
      Boost library location was automatically guessed at /<path>/miniconda3/envs/vina/include.
      - include_dirs: ['/<path>/miniconda3/envs/vina/include/python3.13t', '/<path>/miniconda3/envs/vina/include', 'src/lib']
      - library_dirs: ['/<path>/miniconda3/envs/vina/lib']
      - swig options: ['-c++', '-small', '-naturalvar', '-fastdispatch', '-shadow', '-py3', '-I/<path>/miniconda3/envs/vina/include/python3.13t', '-I/<path>/miniconda3/envs/vina/include', '-Isrc/lib']
      - libraries: []
      - extra link args: ['-lboost_thread', '-lboost_serialization', '-lboost_filesystem', '-lboost_program_options', '-Wl,-rpath,/<path>/miniconda3/envs/vina/lib', '-Wl,-rpath,/usr/lib']
      Warning: compiler flag -Wstrict-prototypes is not present, cannot remove it.
      - compiler options: ['g++', '-fno-strict-overflow', '-shared', '-Wsign-compare', '-Wunreachable-code', '-DNDEBUG', '-O2', '-fPIC', '-O2', '-isystem', '/<path>/miniconda3/envs/vina/include', '-fPIC', '-O2', '-isystem', '/<path>/miniconda3/envs/vina/include', '-std=c++11', '-Wno-long-long', '-pedantic', '-DBOOST_ERROR_CODE_HEADER_ONLY']
      building 'vina._vina_wrapper' extension
      swigging vina/autodock_vina.i to vina/autodock_vina_wrap.cpp
      swig -python -c++ -small -naturalvar -fastdispatch -shadow -py3 -I/<path>/miniconda3/envs/vina/include/python3.13t -I/<path>/miniconda3/envs/vina/include -Isrc/lib -o vina/autodock_vina_wrap.cpp vina/autodock_vina.i
      Deprecated command line option: -py3. Ignored, this option is no longer supported.
      creating build/temp.macosx-10.13-x86_64-cpython-313t/src/lib
      creating build/temp.macosx-10.13-x86_64-cpython-313t/vina
      clang++ -fno-strict-overflow -Wsign-compare -Wunreachable-code -DNDEBUG -O2 -Wall -fPIC -O2 -isystem /<path>/miniconda3/envs/vina/include -fPIC -O2 -isystem /<path>/miniconda3/envs/vina/include -I/<path>/miniconda3/envs/vina/include/python3.13t -I/<path>/miniconda3/envs/vina/include -Isrc/lib -c src/lib/ad4cache.cpp -o build/temp.macosx-10.13-x86_64-cpython-313t/src/lib/ad4cache.o
      In file included from src/lib/ad4cache.cpp:23:
      In file included from src/lib/ad4cache.h:32:
      In file included from /<path>/miniconda3/envs/vina/include/boost/filesystem/fstream.hpp:17:
      In file included from /<path>/miniconda3/envs/vina/include/boost/filesystem/path.hpp:34:
      In file included from /<path>/miniconda3/envs/vina/include/boost/filesystem/detail/path_traits.hpp:26:
      In file included from /<path>/miniconda3/envs/vina/include/boost/system/error_category.hpp:10:
      /<path>/miniconda3/envs/vina/include/boost/system/detail/error_category.hpp:87:5: error: unknown type name 'constexpr'
         87 |     constexpr error_category() noexcept: id_( 0 ), stdcat_(), sc_init_()
            |     ^
      /<path>/miniconda3/envs/vina/include/boost/system/detail/error_category.hpp:87:15: error: constructor cannot have a return type
         87 |     constexpr error_category() noexcept: id_( 0 ), stdcat_(), sc_init_()
            |               ^~~~~~~~~~~~~~
      /<path>/miniconda3/envs/vina/include/boost/system/detail/error_category.hpp:87:31: error: expected ';' at end of declaration list
         87 |     constexpr error_category() noexcept: id_( 0 ), stdcat_(), sc_init_()
            |                               ^
      /<path>/miniconda3/envs/vina/include/boost/system/detail/error_category.hpp:99:68: error: expected ';' at end of declaration list
         99 |     virtual error_condition default_error_condition( int ev ) const noexcept;
            |                                                                    ^
      /<path>/miniconda3/envs/vina/include/boost/system/detail/error_category.hpp:100:81: error: expected ';' at end of declaration list
        100 |     virtual bool equivalent( int code, const error_condition & condition ) const noexcept;
            |                                                                                 ^
      /<path>/miniconda3/envs/vina/include/boost/system/detail/error_category.hpp:101:76: error: expected ';' at end of declaration list
        101 |     virtual bool equivalent( const error_code & code, int condition ) const noexcept;
            |                                                                            ^
      /<path>/miniconda3/envs/vina/include/boost/system/detail/error_category.hpp:104:81: error: expected ';' at end of declaration list
        104 |     virtual char const * message( int ev, char * buffer, std::size_t len ) const noexcept;
            |                                                                                 ^
      /<path>/miniconda3/envs/vina/include/boost/system/detail/error_category.hpp:106:40: error: expected ';' at end of declaration list
        106 |     virtual bool failed( int ev ) const noexcept
            |                                        ^
      In file included from src/lib/ad4cache.cpp:23:
      In file included from src/lib/ad4cache.h:32:
      In file included from /<path>/miniconda3/envs/vina/include/boost/filesystem/fstream.hpp:17:
      In file included from /<path>/miniconda3/envs/vina/include/boost/filesystem/path.hpp:34:
      In file included from /<path>/miniconda3/envs/vina/include/boost/filesystem/detail/path_traits.hpp:26:
      In file included from /<path>/miniconda3/envs/vina/include/boost/system/error_category.hpp:11:
      In file included from /<path>/miniconda3/envs/vina/include/boost/system/detail/error_category_impl.hpp:14:
      In file included from /<path>/miniconda3/envs/vina/include/boost/system/detail/error_condition.hpp:14:
      In file included from /<path>/miniconda3/envs/vina/include/boost/system/detail/generic_category.hpp:14:
      /<path>/miniconda3/envs/vina/include/boost/system/detail/generic_category_message.hpp:71:94: error: expected function body after function declarator
         71 | inline char const * generic_error_category_message( int ev, char * buffer, std::size_t len ) noexcept
            |                                                                                              ^
      In file included from src/lib/ad4cache.cpp:23:
      In file included from src/lib/ad4cache.h:32:
      In file included from /<path>/miniconda3/envs/vina/include/boost/filesystem/fstream.hpp:17:
      In file included from /<path>/miniconda3/envs/vina/include/boost/filesystem/path.hpp:34:
      In file included from /<path>/miniconda3/envs/vina/include/boost/filesystem/detail/path_traits.hpp:26:
      In file included from /<path>/miniconda3/envs/vina/include/boost/system/error_category.hpp:11:
      In file included from /<path>/miniconda3/envs/vina/include/boost/system/detail/error_category_impl.hpp:14:
      In file included from /<path>/miniconda3/envs/vina/include/boost/system/detail/error_condition.hpp:14:
      /<path>/miniconda3/envs/vina/include/boost/system/detail/generic_category.hpp:38:52: error: expected ';' at end of declaration list
         38 |     BOOST_SYSTEM_CONSTEXPR generic_error_category() noexcept:
            |                                                    ^
      /<path>/miniconda3/envs/vina/include/boost/system/detail/generic_category.hpp:49:73: error: expected ';' at end of declaration list
         49 |     char const * message( int ev, char * buffer, std::size_t len ) const noexcept BOOST_OVERRIDE;
            |                                                                         ^
      /<path>/miniconda3/envs/vina/include/boost/system/detail/generic_category.hpp:58:101: error: expected function body after function declarator
         58 | inline char const * generic_error_category::message( int ev, char * buffer, std::size_t len ) const noexcept
            |                                                                                                     ^
      /<path>/miniconda3/envs/vina/include/boost/system/detail/generic_category.hpp:97:50: error: expected function body after function declarator
         97 | inline error_category const & generic_category() noexcept BOOST_SYMBOL_VISIBLE;
            |                                                  ^
      /<path>/miniconda3/envs/vina/include/boost/system/detail/generic_category.hpp:100:50: error: expected function body after function declarator
        100 | inline error_category const & generic_category() noexcept
            |                                                  ^
      In file included from src/lib/ad4cache.cpp:23:
      In file included from src/lib/ad4cache.h:32:
      In file included from /<path>/miniconda3/envs/vina/include/boost/filesystem/fstream.hpp:17:
      In file included from /<path>/miniconda3/envs/vina/include/boost/filesystem/path.hpp:34:
      In file included from /<path>/miniconda3/envs/vina/include/boost/filesystem/detail/path_traits.hpp:26:
      In file included from /<path>/miniconda3/envs/vina/include/boost/system/error_category.hpp:11:
      In file included from /<path>/miniconda3/envs/vina/include/boost/system/detail/error_category_impl.hpp:14:
      /<path>/miniconda3/envs/vina/include/boost/system/detail/error_condition.hpp:53:42: error: expected ';' at end of declaration list
         53 |     boost::ulong_long_type cat_id() const noexcept
            |                                          ^
      In file included from src/lib/ad4cache.cpp:23:
      In file included from src/lib/ad4cache.h:32:
      In file included from /<path>/miniconda3/envs/vina/include/boost/filesystem/fstream.hpp:17:
      In file included from /<path>/miniconda3/envs/vina/include/boost/filesystem/path.hpp:34:
      In file included from /<path>/miniconda3/envs/vina/include/boost/filesystem/detail/path_traits.hpp:26:
      In file included from /<path>/miniconda3/envs/vina/include/boost/system/error_category.hpp:11:
      In file included from /<path>/miniconda3/envs/vina/include/boost/system/detail/error_category_impl.hpp:15:
      In file included from /<path>/miniconda3/envs/vina/include/boost/system/detail/error_code.hpp:16:
      /<path>/miniconda3/envs/vina/include/boost/system/detail/system_category.hpp:37:51: error: expected ';' at end of declaration list
         37 |     BOOST_SYSTEM_CONSTEXPR system_error_category() noexcept:
            |                                                   ^
      /<path>/miniconda3/envs/vina/include/boost/system/detail/system_category.hpp:50:73: error: expected ';' at end of declaration list
         50 |     char const * message( int ev, char * buffer, std::size_t len ) const noexcept BOOST_OVERRIDE;
            |                                                                         ^
      /<path>/miniconda3/envs/vina/include/boost/system/detail/system_category.hpp:86:49: error: expected function body after function declarator
         86 | inline error_category const & system_category() noexcept BOOST_SYMBOL_VISIBLE;
            |                                                 ^
      /<path>/miniconda3/envs/vina/include/boost/system/detail/system_category.hpp:89:49: error: expected function body after function declarator
         89 | inline error_category const & system_category() noexcept
            |                                                 ^
      fatal error: too many errors emitted, stopping now [-ferror-limit=]
      20 errors generated.
      error: command '/usr/bin/clang++' failed with exit code 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for vina
Failed to build vina
ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (vina)

@diogomart
Copy link
Contributor

Alternatively, you could install from conda-forge (e.g. micromamba install vina), it installs both the Python bindings and the executable.

@ivnsch
Copy link
Author

ivnsch commented Dec 27, 2024

I did a new install again and was able to follow the tutorial's basic docking example. Since I can't reproduce the original issue anymore and there has been no other reports, I'll close it, thanks!

@ivnsch ivnsch closed this as completed Dec 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants