简体   繁体   中英

How to install apache-libcloud on ubuntu

I am having issues with libcloud install on ubuntu with python 2.7.2

I installed libcloud from the apache libcloud website http://libcloud.apache.org/downloads.html . The apache-libcloud-0.9.1.zip file.

When I follow the examples I can import libcloud but when trying to import the libraries from the examples I get the error below:

import sys
import os
import libcloud
from libcloud.compute.types import Provider
from libcloud.compute.providers import get_driver

Traceback (most recent call last):
  File "/home/ubuntu/workspace/rtbopsConfig/test_code/libcloud.py", line 3, in <module>
    import libcloud
  File "/home/ubuntu/workspace/rtbopsConfig/test_code/libcloud.py", line 4, in <module>
    from libcloud.compute.types import Provider
ImportError: No module named compute.types

I did have a previous version install but when I found out the package was out of date I installed it from source. I did use the package installer remover.

So... how to resolve this? Packages are in /usr/local/lib/python2.7/dist-packages/libcloud/

Use pip to install libcloud

pip install apache-libcloud

As the file libcloud/compute/types.py exists in the archive you mentioned, there seems to be a problem concerning the installed version. (The imports actually work for me.)

You can try to remove and reinstall it (make sure that you first remove all related packages installed using apt-get/aptitude).

$ sudo pip uninstall libcloud
$ cd /path/to/downloaded/archive
$ sudo python setup.py install

If you want to debug the issue, you can usually get the library version using

>>> import libcloud
>>> print libcloud.__version__
0.9.1

What did you call your python file that you had this issue with? if you called it libcloud.py it could cause this exact issue.

To fix, simply name your file something else and try running it again. Also make sure you remove and libcloud.pyc file in the same directory.

What's happening is that python thinks your libcloud.py file IS the libcloud you're trying to import, which obviously doesn't work since you don't define compute and such.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM