getting error while using docker-compose build: __init__() got an unexpected keyword argument 'interpolate'

Viewed 2048

I am new to docker and while running docker-compose build command i am getting this error.

Traceback (most recent call last):                                                                   
  File "/home/ghostface/playground/bootcamp/venv/bin/docker-compose", line 11, in <module>
    sys.exit(main())                                                                                      
  File "/home/ghostface/playground/bootcamp/venv/lib/python3.6/site-packages/compose/cli/main.py", line 72, in main
    command()
  File "/home/ghostface/playground/bootcamp/venv/lib/python3.6/site-packages/compose/cli/main.py", line 125, in perform_command
    project = project_from_options('.', options)
  File "/home/ghostface/playground/bootcamp/venv/lib/python3.6/site-packages/compose/cli/command.py", line 76, in project_from_options
    environment_file=environment_file
  File "/home/ghostface/playground/bootcamp/venv/lib/python3.6/site-packages/compose/cli/command.py", line 135, in get_project
    config_data = config.load(config_details, compatibility, interpolate)
  File "/home/ghostface/playground/bootcamp/venv/lib/python3.6/site-packages/compose/config/config.py", line 411, in load
    service_dicts = load_services(config_details, main_file, compatibility, interpolate=interpolate)
  File "/home/ghostface/playground/bootcamp/venv/lib/python3.6/site-packages/compose/config/config.py", line 510, in load_services
    return build_services(service_config)
  File "/home/ghostface/playground/bootcamp/venv/lib/python3.6/site-packages/compose/config/config.py", line 491, in build_services
    for name, service_dict in service_config.items()
  File "/home/ghostface/playground/bootcamp/venv/lib/python3.6/site-packages/compose/config/config.py", line 491, in <listcomp>
    for name, service_dict in service_config.items()
  File "/home/ghostface/playground/bootcamp/venv/lib/python3.6/site-packages/compose/config/config.py", line 483, in build_service
    interpolate
  File "/home/ghostface/playground/bootcamp/venv/lib/python3.6/site-packages/compose/config/config.py", line 888, in finalize_service
    service_dict['environment'] = resolve_environment(service_dict, environment, interpolate)
  File "/home/ghostface/playground/bootcamp/venv/lib/python3.6/site-packages/compose/config/config.py", line 687, in resolve_environment
    env.update(env_vars_from_file(env_file, interpolate))
  File "/home/ghostface/playground/bootcamp/venv/lib/python3.6/site-packages/compose/config/environment.py", line 42, in env_vars_from_file
    env = dotenv.dotenv_values(dotenv_path=filename, encoding='utf-8-sig', interpolate=interpolate)
  File "/home/ghostface/playground/bootcamp/venv/lib/python3.6/site-packages/dotenv/main.py", line 283, in dotenv_values
    return DotEnv(f, verbose=verbose, **kwargs).dict()
TypeError: __init__() got an unexpected keyword argument 'interpolate' 

Result of docker-compose version

docker-compose version 1.26.0, build unknown
docker-py version: 4.2.1
CPython version: 3.6.8
OpenSSL version: OpenSSL 1.1.1c 28 May 2019

Requirement.txt file:

Flask==1.1.1          
Flask-Login==0.4.1             
Flask-Mail==0.9.1                
Flask-Migrate==2.5.2                   
Flask-Moment==0.9.0                
Flask-SQLAlchemy==2.4.0                 
Flask-WTF==0.14.2            
pusher==2.1.4            
PyJWT==1.7.1           
pylint==2.3.1               
python-dotenv==0.10.3                
Werkzeug==0.16.1                       
gunicorn       
docker-compose             
1 Answers

The code in your container uses a newer version of python-dotenv than the one that is listed in the requirements.txt file, as the interpolate option was added in v0.11.0.

You will need to change the version in requirements.txt to 0.11.0 (or the most recent one) and reinstall the dependencies.

It seems your container uses a virtual environment. You may need to check that the dependencies are correctly updated in the container, either by running pip install in the Dockerfile, or by running it locally beforehand.

Related