adamewing / tldr

Identify and annotate TE-mediated insertions in long-read sequence data
MIT License
40 stars 4 forks source link

AttributeError: module '__main__' has no attribute '__spec__' #30

Open raquelgarza opened 1 year ago

raquelgarza commented 1 year ago

Hi!

I'm trying to run tldr on a conda container - which i created following your instructions loyally - but it ends as soon as it starts with the following error:

2023-04-27 15:59:37,266 tldr started with command: /Users/raquelgarza/opt/anaconda3/envs/tldr/bin/tldr -b /Users/raquelgarza/Desktop/op_043/1_mapping/op_043_001.sorted.bam -e /Users/raquelgarza/Desktop/op_043/resources/teref.human.fa -r /Users/raquelgarza/Desktop/op_043/resources/GRCh38.p13/GRCh38.p13.genome.fa
2023-04-27 15:59:37,266 output basename: op_043_001.sorted
Traceback (most recent call last):
  File "/Users/raquelgarza/opt/anaconda3/envs/tldr/bin/tldr", line 4, in <module>
    __import__('pkg_resources').run_script('tldr==1.2.2', 'tldr')
  File "/Users/raquelgarza/opt/anaconda3/envs/tldr/lib/python3.10/site-packages/pkg_resources/__init__.py", line 672, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/Users/raquelgarza/opt/anaconda3/envs/tldr/lib/python3.10/site-packages/pkg_resources/__init__.py", line 1479, in run_script
    exec(script_code, namespace, namespace)
  File "/Users/raquelgarza/opt/anaconda3/envs/tldr/lib/python3.10/site-packages/tldr-1.2.2-py3.10.egg/EGG-INFO/scripts/tldr", line 2128, in <module>
  File "/Users/raquelgarza/opt/anaconda3/envs/tldr/lib/python3.10/site-packages/tldr-1.2.2-py3.10.egg/EGG-INFO/scripts/tldr", line 1861, in main
  File "/Users/raquelgarza/opt/anaconda3/envs/tldr/lib/python3.10/multiprocessing/context.py", line 119, in Pool
    return Pool(processes, initializer, initargs, maxtasksperchild,
  File "/Users/raquelgarza/opt/anaconda3/envs/tldr/lib/python3.10/multiprocessing/pool.py", line 212, in __init__
    self._repopulate_pool()
  File "/Users/raquelgarza/opt/anaconda3/envs/tldr/lib/python3.10/multiprocessing/pool.py", line 303, in _repopulate_pool
    return self._repopulate_pool_static(self._ctx, self.Process,
  File "/Users/raquelgarza/opt/anaconda3/envs/tldr/lib/python3.10/multiprocessing/pool.py", line 326, in _repopulate_pool_static
    w.start()
  File "/Users/raquelgarza/opt/anaconda3/envs/tldr/lib/python3.10/multiprocessing/process.py", line 121, in start
    self._popen = self._Popen(self)
  File "/Users/raquelgarza/opt/anaconda3/envs/tldr/lib/python3.10/multiprocessing/context.py", line 284, in _Popen
    return Popen(process_obj)
  File "/Users/raquelgarza/opt/anaconda3/envs/tldr/lib/python3.10/multiprocessing/popen_spawn_posix.py", line 32, in __init__
    super().__init__(process_obj)
  File "/Users/raquelgarza/opt/anaconda3/envs/tldr/lib/python3.10/multiprocessing/popen_fork.py", line 19, in __init__
    self._launch(process_obj)
  File "/Users/raquelgarza/opt/anaconda3/envs/tldr/lib/python3.10/multiprocessing/popen_spawn_posix.py", line 42, in _launch
    prep_data = spawn.get_preparation_data(process_obj._name)
  File "/Users/raquelgarza/opt/anaconda3/envs/tldr/lib/python3.10/multiprocessing/spawn.py", line 183, in get_preparation_data
    main_mod_name = getattr(main_module.__spec__, "name", None)
AttributeError: module '__main__' has no attribute '__spec__'

Any ideas what this could mean? Is my command incorrect somehow?

adamewing commented 1 year ago

Hmm, what system are you running this on (i.e. linux, windows/wsl, ...) and is it being run from within anything else (jupyter, spyder)? Also are you able to run the test (cd tldr/test && ./run_test.sh)?

raquelgarza commented 1 year ago

Hi again!

Sorry, I should have left you some details. I'm running this on macos Catalina version 10.15.7, conda version 22.11.1. Tldr is running inside the conda environment, but not anything else (jupyter, spyder..)

The test fails with the same error:

2023-04-28 09:29:07,533 tldr started with command: /Users/raquelgarza/opt/anaconda3/envs/tldr/bin/tldr -b test.bam -e ../ref/teref.human.fa -r ref.fa --color_consensus
2023-04-28 09:29:07,533 output basename: test
Traceback (most recent call last):
  File "/Users/raquelgarza/opt/anaconda3/envs/tldr/bin/tldr", line 4, in <module>
    __import__('pkg_resources').run_script('tldr==1.2.2', 'tldr')
  File "/Users/raquelgarza/opt/anaconda3/envs/tldr/lib/python3.10/site-packages/pkg_resources/__init__.py", line 672, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/Users/raquelgarza/opt/anaconda3/envs/tldr/lib/python3.10/site-packages/pkg_resources/__init__.py", line 1479, in run_script
    exec(script_code, namespace, namespace)
  File "/Users/raquelgarza/opt/anaconda3/envs/tldr/lib/python3.10/site-packages/tldr-1.2.2-py3.10.egg/EGG-INFO/scripts/tldr", line 2128, in <module>
  File "/Users/raquelgarza/opt/anaconda3/envs/tldr/lib/python3.10/site-packages/tldr-1.2.2-py3.10.egg/EGG-INFO/scripts/tldr", line 1861, in main
  File "/Users/raquelgarza/opt/anaconda3/envs/tldr/lib/python3.10/multiprocessing/context.py", line 119, in Pool
    return Pool(processes, initializer, initargs, maxtasksperchild,
  File "/Users/raquelgarza/opt/anaconda3/envs/tldr/lib/python3.10/multiprocessing/pool.py", line 212, in __init__
    self._repopulate_pool()
  File "/Users/raquelgarza/opt/anaconda3/envs/tldr/lib/python3.10/multiprocessing/pool.py", line 303, in _repopulate_pool
    return self._repopulate_pool_static(self._ctx, self.Process,
  File "/Users/raquelgarza/opt/anaconda3/envs/tldr/lib/python3.10/multiprocessing/pool.py", line 326, in _repopulate_pool_static
    w.start()
  File "/Users/raquelgarza/opt/anaconda3/envs/tldr/lib/python3.10/multiprocessing/process.py", line 121, in start
    self._popen = self._Popen(self)
  File "/Users/raquelgarza/opt/anaconda3/envs/tldr/lib/python3.10/multiprocessing/context.py", line 284, in _Popen
    return Popen(process_obj)
  File "/Users/raquelgarza/opt/anaconda3/envs/tldr/lib/python3.10/multiprocessing/popen_spawn_posix.py", line 32, in __init__
    super().__init__(process_obj)
  File "/Users/raquelgarza/opt/anaconda3/envs/tldr/lib/python3.10/multiprocessing/popen_fork.py", line 19, in __init__
    self._launch(process_obj)
  File "/Users/raquelgarza/opt/anaconda3/envs/tldr/lib/python3.10/multiprocessing/popen_spawn_posix.py", line 42, in _launch
    prep_data = spawn.get_preparation_data(process_obj._name)
  File "/Users/raquelgarza/opt/anaconda3/envs/tldr/lib/python3.10/multiprocessing/spawn.py", line 183, in get_preparation_data
    main_mod_name = getattr(main_module.__spec__, "name", None)
AttributeError: module '__main__' has no attribute '__spec__'
adamewing commented 1 year ago

I don't have access to anything running macos right now so will have you try the following, after this line in tldr: https://github.com/adamewing/tldr/blob/821f30a77ccc2ee454c904b95a61474ae9701646/tldr/tldr#L2120

Could you add the following code: __spec__ = None

so it should look like:

if __name__ == '__main__':
    __spec__ = None
    parser = argparse.ArgumentParser(description='Find TE insertions in ONT data')

Then reinstall (python setup.py install) and see if anything changes.

raquelgarza commented 1 year ago

Hi again!

I tried this. Got a different error. The error after "The above exception was the direct cause of the following exception:" is looped

2023-05-02 09:48:06,524 tldr started with command: /Users/raquelgarza/opt/anaconda3/envs/tldr/bin/tldr -b test.bam -e ../ref/teref.human.fa -r ref.fa --color_consensus
2023-05-02 09:48:06,524 output basename: test
Traceback (most recent call last):
  File "/Users/raquelgarza/opt/anaconda3/envs/tldr/lib/python3.10/runpy.py", line 238, in _get_main_module_details
    return _get_module_details(main_name)
  File "/Users/raquelgarza/opt/anaconda3/envs/tldr/lib/python3.10/runpy.py", line 140, in _get_module_details
    raise error("No module named %s" % mod_name)
ImportError: No module named __main__

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/raquelgarza/opt/anaconda3/envs/tldr/lib/python3.10/multiprocessing/spawn.py", line 116, in spawn_main
    exitcode = _main(fd, parent_sentinel)
  File "/Users/raquelgarza/opt/anaconda3/envs/tldr/lib/python3.10/multiprocessing/spawn.py", line 125, in _main
    prepare(preparation_data)
  File "/Users/raquelgarza/opt/anaconda3/envs/tldr/lib/python3.10/multiprocessing/spawn.py", line 236, in prepare
    _fixup_main_from_path(data['init_main_from_path'])
  File "/Users/raquelgarza/opt/anaconda3/envs/tldr/lib/python3.10/multiprocessing/spawn.py", line 287, in _fixup_main_from_path
    main_content = runpy.run_path(main_path,
  File "/Users/raquelgarza/opt/anaconda3/envs/tldr/lib/python3.10/runpy.py", line 302, in run_path
    mod_name, mod_spec, code = _get_main_module_details()
  File "/Users/raquelgarza/opt/anaconda3/envs/tldr/lib/python3.10/runpy.py", line 241, in _get_main_module_details
    raise error("can't find %r module in %r" %
ImportError: can't find '__main__' module in '/Users/raquelgarza/opt/anaconda3/envs/tldr/lib/python3.10/site-packages/tldr-1.2.2-py3.10.egg/EGG-INFO/scripts/tldr'
Traceback (most recent call last):
  File "/Users/raquelgarza/opt/anaconda3/envs/tldr/lib/python3.10/runpy.py", line 238, in _get_main_module_details
    return _get_module_details(main_name)
  File "/Users/raquelgarza/opt/anaconda3/envs/tldr/lib/python3.10/runpy.py", line 140, in _get_module_details
    raise error("No module named %s" % mod_name)
ImportError: No module named __main__