question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AttributeError: 'module' object has no attribute 'from_env'

See original GitHub issue

Currently on OS X El Capitan 10.11.6

$ pip freeze | grep docker && python --version && docker version
docker==2.0.0
docker-compose==1.7.0
docker-py==1.8.1
docker-pycreds==0.2.1
dockerpty==0.4.1
Python 2.7.11
Client:
 Version:      1.12.5
 API version:  1.24
 Go version:   go1.6.4
 Git commit:   7392c3b
 Built:        Fri Dec 16 06:14:34 2016
 OS/Arch:      darwin/amd64

Server:
 Version:      1.12.5
 API version:  1.24
 Go version:   go1.6.4
 Git commit:   7392c3b
 Built:        Fri Dec 16 06:14:34 2016
 OS/Arch:      linux/amd64

Attempting to run test file with contents of:

import docker
client = docker.from_env()

Following error:

$ python docker.py
Traceback (most recent call last):
  File "docker.py", line 1, in <module>
    import docker
  File "/Users/docker.py", line 3, in <module>
    client = docker.from_env()
AttributeError: 'module' object has no attribute 'from_env'

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:7
  • Comments:6

github_iconTop GitHub Comments

14reactions
emsladecommented, Jan 10, 2017

@narenst Looks like there was a file named docker.py which was being imported instead of the docker library.

1reaction
caio-viniciuscommented, Oct 1, 2020

Solution: the name of the file need to be different from “docker.py”

Read more comments on GitHub >

github_iconTop Results From Across the Web

AttributeError: 'module' object has no attribute 'Environment'
From your traceback it seems as if the script you are trying to run is named lmdb.py . Change its name to something...
Read more >
authconfig command failing with error "AttributeError
No translations currently exist. Issue. authconfig command failing with error AttributeError: 'module' object has no attribute 'SSSDConfig' .
Read more >
Python SPSS - 'module' object has no attribute 'submit' - IBM
Hello, I'm new here but I've been following the threads. When executing the following Python/spss code, I<br> get an Attribute Error - I...
Read more >
[Solved] AttributeError: 'module' object has no attribute
Click here to subscribe - https://www.youtube.com/channel/UCeVMnSShP_Iviwkknt83cww▻Instagram ...
Read more >
'module' object has no attribute 'CounterflowDiffusionFlame'
AttributeError : 'module' object has no attribute 'CounterflowDiffusionFlame'. I do not know how to solve those. It is the code provided as tutorial....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found