replicate / cog

Containers for machine learning
https://cog.run
Apache License 2.0
7.52k stars 522 forks source link

Error while finding module specification for 'cog.server.http' (ModuleNotFoundError: No module named 'cog') #1591

Open Aparna29T opened 4 months ago

Aparna29T commented 4 months ago

**Error: Error while finding module specification for 'cog.server.http' (ModuleNotFoundError: No module named 'cog')** Not able to use run command inside build section in cog.yaml

Below is my cog yaml.

build:
  gpu: false
  python_packages:
  - "pandas==1.4.3"
  - "scikit-learn==1.3.0"
  - "numpy==1.23.2"
  - "nltk==3.7"
  - "gensim==4.2.0"
  - "sentence-transformers==2.5.1"
  - "joblib==1.2.0"
  - "Flask==3.0.2"
  - "torch==1.12.1"
  python_version: "3.10.6"
  run:
    - command: "python -m pip install nltk && python -m nltk.downloader all"
predict: "predict.py:Predictor"

instead of

run:
    - command: "python -m pip install nltk && python -m nltk.downloader all"

tried

build:
  run:
    - "python -m nltk.downloader stopwords && \
      python -m nltk.downloader punkt && \
      python -m nltk.downloader wordnet && \
      python -m nltk.downloader omw-1.4"

If I try to run only cog build -t tagname

Error: Validating model schema... /usr/local/bin/python: Error while finding module specification for 'cog.command.openapi_schema' (ModuleNotFoundError: No module named 'cog')

Is RUN command not supported? If so how I can install below commands in cog.yaml

  python -m nltk.downloader stopwords
  python -m nltk.downloader punkt
  python -m nltk.downloader wordnet
  python -m nltk.downloader omw-1.4
Aparna29T commented 3 months ago

@bfirsh @anotherjesse Any update here?

CodeDetector commented 2 months ago

same issue

mattt commented 1 month ago

Hi, @Aparna29T.

Based on the error message you shared, it looks like the python command run in the GenerateOpenAPISchema function doesn't have a the Cog Python package installed.

Can you please try running the following command and trying again?

/usr/local/bin/python -m pip install cog