nf-core / tools

Python package with helper tools for the nf-core community.
https://nf-co.re
MIT License
244 stars 192 forks source link

I get an error about the imp module in python12 #3173

Closed kojix2 closed 2 months ago

kojix2 commented 2 months ago

Description of the bug

Hello,

I have installed nf-core and Nextflow using Micromamba. The installation was successful, but when I run the nf-core command, I receive the following error:

Traceback (most recent call last):
  File "/Users/kojix2/miniconda3/envs/nextflow/bin/nf-core", line 7, in <module>
    from nf_core.__main__ import run_nf_core
  File "/Users/kojix2/miniconda3/envs/nextflow/lib/python3.12/site-packages/nf_core/__main__.py", line 19, in <module>
    import nf_core.lint
  File "/Users/kojix2/miniconda3/envs/nextflow/lib/python3.12/site-packages/nf_core/lint/__init__.py", line 22, in <module>
    import nf_core.modules.lint
  File "/Users/kojix2/miniconda3/envs/nextflow/lib/python3.12/site-packages/nf_core/modules/__init__.py", line 12, in <module>
    from .mulled import MulledImageNameGenerator
  File "/Users/kojix2/miniconda3/envs/nextflow/lib/python3.12/site-packages/nf_core/modules/mulled.py", line 10, in <module>
    from galaxy.tool_util.deps.mulled.util import build_target, v2_image_name
  File "/Users/kojix2/miniconda3/envs/nextflow/lib/python3.12/site-packages/galaxy/tool_util/deps/__init__.py", line 10, in <module>
    from galaxy.util import (
  File "/Users/kojix2/miniconda3/envs/nextflow/lib/python3.12/site-packages/galaxy/util/__init__.py", line 74, in <module>
    from .path import safe_contains, safe_makedirs, safe_relpath  # noqa: F401
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kojix2/miniconda3/envs/nextflow/lib/python3.12/site-packages/galaxy/util/path/__init__.py", line 5, in <module>
    import imp
ModuleNotFoundError: No module named 'imp'

I believe this issue is related to the removal of the imp module in Python 3.12. While this seems to be a Galaxy-related issue and not directly caused by nf-core, I wanted to report it here for reference, as the error still occurs even after following the installation steps in the README.

In my case, the simplest solution was to downgrade to Python 3.11:

conda install python=11

Thank you!

Command used and terminal output

conda create --name nextflow python=3.12 nf-core nextflow
conda activate nextflow
nf-core

System information

Apple M2 macOS Sonoma 14.6.1 micromamba 1.5.9 nextflow version 24.04.4.5917 nf-core, version 2.4.1

mirpedrol commented 2 months ago

Hi @kojix2, looks like you are using an old version of nf-core, the current stable version is 2.14.1. I recommend installing the latest version where you shouldn't see this error.

kojix2 commented 2 months ago

Thank you, I have updated nf-core to the latest version and this error no longer occurs. The reason why the latest nf-core could not be installed automatically is that the version of pytest-workflow was out of date. bioconda has a higher priority than conda-forge and the pytest-workflow registered in bioconda was out of date.

conda search -c bioconda pytest-workflow
Loading channels: done
# Name                       Version           Build  Channel
pytest-workflow                1.1.0            py_0  bioconda
pytest-workflow                1.1.1            py_0  bioconda
pytest-workflow                1.1.2            py_0  bioconda
pytest-workflow                1.2.0            py_0  bioconda
pytest-workflow                1.2.0            py_0  conda-forge
pytest-workflow                1.2.1            py_0  conda-forge
pytest-workflow                1.2.2            py_0  conda-forge
pytest-workflow                1.2.3            py_0  conda-forge
pytest-workflow                1.3.0            py_0  conda-forge
pytest-workflow                1.4.0            py_0  conda-forge
pytest-workflow                1.5.0    pyhd8ed1ab_0  conda-forge
pytest-workflow                1.6.0    pyhd8ed1ab_0  conda-forge
pytest-workflow                2.0.0    pyhd8ed1ab_0  conda-forge
pytest-workflow                2.0.1    pyhd8ed1ab_0  conda-forge
pytest-workflow                2.1.0    pyhd8ed1ab_0  conda-forge

It was necessary to manually upgrade pytest-workflow by specifying the conda-forge channel.