I have a problem. I want to use the docker-py(0.4.0) library, but i cannot import it. My code looks as followed:
docker.py
import docker
c = docker.Client()
c.info()
then i get this error message:
Traceback (most recent call last):
File "./docker.py", line 1, in <module>
import docker
File "/home/vagrant/docker.py", line 3, in <module>
c = docker.Client()
AttributeError: 'module' object has no attribute 'Client'
when i run it from the python interpreter it works
>>> import docker
>>> c = docker.Client()
>>> c.info()
{u'KernelVersion': u'3.13.0-35-generic', u'NFd': 12, u'MemoryLimit': 1,
u'InitSha1': u'',u'SwapLimit': 0, u'Driver': u'devicemapper',
u'IndexServerAddress': u'https://index.docker.io/v1/', u'NGoroutines': 11,
u'Images': 310, u'InitPath': u'/usr/bin/docker', u'Containers': 1,
u'ExecutionDriver': u'native-0.2', u'Debug': 0, u'NEventsListener': 0,
u'DriverStatus': [[u'Pool Name', u'docker-8:1-140095-pool'],
[u'Pool Blocksize', u'64 Kb'], [u'Data file', /var/lib/docker/devicemapper/devicemapper/data'], [u'Metadata file', u'/var/lib/docker/devicemapper/devicemapper/metadata'],
[u'Data Space Used', u'3602.1 Mb'], [u'Data Space Total', u'102400.0 Mb'],
[u'Metadata Space Used', u'8.7 Mb'], [u'Metadata Space Total', u'2048.0 Mb']],
u'OperatingSystem': u'Ubuntu 14.04.1 LTS', u'IPv4Forwarding': 1}
>>>
I don't use any virtualenv, only the system python. I have try it on two machines, but same result
Can someone explaine me what i am doing wrong?
your filename is docker.py and when you say import docker it tries to import itself. Try renaming your file and run it again
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With