facebookresearch / demucs

Code for the paper Hybrid Spectrogram and Waveform Source Separation
MIT License
8.37k stars 1.07k forks source link

No module named 'demucs.api'; 'demucs' is not a package #576

Closed gillbates closed 11 months ago

gillbates commented 11 months ago

🐛 Bug Report

it seemed we cannot import demucs in our own python code?

To Reproduce

(Write your steps here:)

  1. init a new conda env with
    conda create --name mydemucs python=3.9 -y

    2, activate conda env

    conda activate mydemucs

3, install the edge version with

python3 -m pip install -U git+https://github.com/facebookresearch/demucs#egg=demucs

4, using the following code

import demucs.api

if __name__ == '__main__':
     separator = demucs.api.Separator()

it shows

ModuleNotFoundError: No module named 'demucs.api'; 'demucs' is not a package

Expected behavior

we could import and use demucs api correctly ...

Actual Behavior

it shows

ModuleNotFoundError: No module named 'demucs.api'; 'demucs' is not a package

Your Environment

gillbates commented 11 months ago

@CarlGao4 did u ever meet this?

CarlGao4 commented 11 months ago
  1. The official repo is adefossez/demucs now
  2. Please run pip show demucs and see whether it's correctly installed
gillbates commented 11 months ago

@CarlGao4

pip show demucs

Name: demucs
Version: 4.1.0a2
Summary: Music source separation in the waveform domain.
Home-page: https://github.com/facebookresearch/demucs
Author: Alexandre Défossez
Author-email: defossez@fb.com
License: MIT License
Location: /home/xxx/miniconda3/envs/mydemucs/lib/python3.9/site-packages
Requires: dora-search, einops, julius, lameenc, openunmix, pyyaml, torch, torchaudio, tqdm
Required-by: 
CarlGao4 commented 11 months ago

That's so interesting... I can't reproduce. Maybe can you run ls /home/xxx/miniconda3/envs/mydemucs/lib/python3.9/site-packages/demucs?

gillbates commented 11 months ago
ls /home/xxx/miniconda3/envs/mydemucs/lib/python3.9/site-packages/demucs

api.py    audio.py    demucs.py   ema.py       hdemucs.py   __init__.py  pretrained.py  py.typed  repitch.py  separate.py  spec.py    svd.py    transformer.py  wav.py
apply.py  augment.py  distrib.py  evaluate.py  htdemucs.py  __main__.py  __pycache__    remote    repo.py     solver.py    states.py  train.py  utils.py        wdemucs.py

it seemed everything is included already.

CarlGao4 commented 11 months ago

Are you sure you've activated the environment before running your script?

gillbates commented 11 months ago

Are you sure you've activated the environment before running your script?

yes .... already several times ... it could be found even in site-packages in pycharm ...

CleanShot 2023-12-11 at 23 16 39@2x

CarlGao4 commented 11 months ago

Can you run this:

import sys
print("\n".join(sys.path))
gillbates commented 11 months ago

Python 3.9.18 (main, Sep 11 2023, 13:41:44)
[GCC 11.2.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print("\n".join(sys.path))

/home/xxx/miniconda3/envs/mydemucs/lib/python39.zip
/home/xxx/miniconda3/envs/mydemucs/lib/python3.9
/home/xxx/miniconda3/envs/mydemucs/lib/python3.9/lib-dynload
/home/xxx/miniconda3/envs/mydemucs/lib/python3.9/site-packages
/home/xxx/miniconda3/envs/mydemucs/lib/python3.9/site-packages/proglog-0.1.10-py3.9.egg
CarlGao4 commented 11 months ago

Maybe... You can try importing it like this:

import demucs
import demucs.api
if __name__ == "__main__":
   ...
gillbates commented 11 months ago

@CarlGao4 I fixed this by re-install conda instead of miniconda ... thx !!!