Skip to content

ImportError: cannot import name 'ParamSpec' from 'typing_extensions' #592

@phamquiluan

Description

@phamquiluan

I got this issue when I tried to follow this tutorial. A minimal reproducible cog.yaml

build:
  python_version: "3.8"
  python_packages:
    - pillow==8.3.1
    - tensorflow==2.5.0

Run cog build, we'll get this

(ins)luan@tuf:~/research/cog-quickstart$ cog build                                                                                                            
Building Docker image from environment in cog.yaml as cog-cog-quickstart...                                                                                   
[+] Building 4.1s (14/14) FINISHED                                                                                                                            
 => [internal] load build definition from Dockerfile                                                                                                     0.0s 
 => => transferring dockerfile: 622B                                                                                                                     0.0s 
 => [internal] load .dockerignore                                                                                                                        0.0s                                 
 => => transferring context: 2B                                                                                                                          0.0s                                 
 => resolve image config for docker.io/docker/dockerfile:1.2                                                                                             1.2s                                 
 => CACHED docker-image://docker.io/docker/dockerfile:1.2@sha256:e2a8561e419ab1ba6b2fe6cbdf49fd92b95912df1cf7d313c3e2230a333fdbcc                        0.0s                                 
 => [internal] load metadata for docker.io/library/python:3.8                                                                                            1.2s                                 
 => [stage-0 1/6] FROM docker.io/library/python:3.8@sha256:f732d55571549b427e12edb89d0951372e7b73c67f717ad0645bb0cda19fc05e                              0.0s 
 => [internal] load build context                                                                                                                        0.4s 
 => => transferring context: 105.91MB                                                                                                                    0.4s 
 => CACHED [stage-0 2/6] COPY .cog/tmp/build2578025161/cog-0.0.1.dev-py3-none-any.whl /tmp/cog-0.0.1.dev-py3-none-any.whl                                0.0s 
 => CACHED [stage-0 3/6] RUN --mount=type=cache,target=/root/.cache/pip pip install /tmp/cog-0.0.1.dev-py3-none-any.whl                                  0.0s 
 => CACHED [stage-0 4/6] RUN --mount=type=cache,target=/root/.cache/pip pip install   pillow==8.3.1 tensorflow==2.5.0                                    0.0s 
 => CACHED [stage-0 5/6] WORKDIR /src                                                                                                                    0.0s                                                                                 
 => [stage-0 6/6] COPY . /src                                                                                                                            0.6s                                                                                 
 => exporting to image                                                                                                                                   0.0s                                                                                 
 => => exporting layers                                                                                                                                  0.0s                                                                                 
 => => writing image sha256:f0def1a441798ec882f8e39c3d029283cec2d341724424cde7350e247664352d                                                             0.0s                                                                                 
 => => naming to docker.io/library/cog-cog-quickstart                                                                                                    0.0s                                                                                 
 => exporting cache                                                                                                                                      0.0s                                                                                 
 => => preparing build cache for export                                                                                                                  0.0s                                                                                 
Adding labels to image...                                  

Traceback (most recent call last):                         
  File "/usr/local/lib/python3.8/runpy.py", line 194, in _run_module_as_main                                           
    return _run_code(code, main_globals, None,                                                                         
  File "/usr/local/lib/python3.8/runpy.py", line 87, in _run_code                                                      
    exec(code, run_globals)                                
  File "/usr/local/lib/python3.8/site-packages/cog/command/openapi_schema.py", line 12, in <module>                                                                                                                                           
    from ..server.http import create_app                                                                               
  File "/usr/local/lib/python3.8/site-packages/cog/server/http.py", line 5, in <module>                                                                                                                                                       
    from fastapi import Body, FastAPI, HTTPException                                                                   
  File "/usr/local/lib/python3.8/site-packages/fastapi/__init__.py", line 7, in <module>                                                                                                                                                      
    from .applications import FastAPI as FastAPI                                                                       
  File "/usr/local/lib/python3.8/site-packages/fastapi/applications.py", line 4, in <module>                                                                                                                                                  
    from fastapi import routing                            
  File "/usr/local/lib/python3.8/site-packages/fastapi/routing.py", line 22, in <module>                                                                                                                                                      
    from fastapi.datastructures import Default, DefaultPlaceholder                                                     
  File "/usr/local/lib/python3.8/site-packages/fastapi/datastructures.py", line 3, in <module>                                                                                                                                                
    from starlette.datastructures import URL as URL  # noqa: F401                                                      
  File "/usr/local/lib/python3.8/site-packages/starlette/datastructures.py", line 8, in <module>                                                                                                                                              
    from starlette.concurrency import run_in_threadpool                                                                
  File "/usr/local/lib/python3.8/site-packages/starlette/concurrency.py", line 10, in <module>                                                                                                                                                
    from typing_extensions import ParamSpec                                                                            
ImportError: cannot import name 'ParamSpec' from 'typing_extensions' (/usr/local/lib/python3.8/site-packages/typing_extensions.py)                                                                                                            

ⅹ Failed to get type signature: exit status 1                       

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions