简体   繁体   English

如何在 ubuntu 上安装 apache-libcloud

[英]How to install apache-libcloud on ubuntu

I am having issues with libcloud install on ubuntu with python 2.7.2我在 ubuntu 和 python 2.7.2 上安装 libcloud 时遇到问题

I installed libcloud from the apache libcloud website http://libcloud.apache.org/downloads.html .我从 apache libcloud 网站http://libcloud.apache.org/downloads.html安装了 libcloud。 The apache-libcloud-0.9.1.zip file. apache-libcloud-0.9.1.zip 文件。

When I follow the examples I can import libcloud but when trying to import the libraries from the examples I get the error below:当我按照示例进行操作时,我可以导入 libcloud 但是当尝试从示例中导入库时,出现以下错误:

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.我确实安装了以前的版本,但是当我发现 package 已经过时时,我从源代码安装了它。 I did use the package installer remover.我确实使用了 package 安装程序删除程序。

So... how to resolve this?那么...如何解决这个问题? Packages are in /usr/local/lib/python2.7/dist-packages/libcloud/包在 /usr/local/lib/python2.7/dist-packages/libcloud/

Use pip to install libcloud使用 pip 安装 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.由于文件libcloud/compute/types.py存在于您提到的存档中,因此安装的版本似乎存在问题。 (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).您可以尝试删除并重新安装它(确保您首先删除使用 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?您将遇到此问题的 python 文件命名为什么? if you called it libcloud.py it could cause this exact issue.如果您将其命名为 libcloud.py,它可能会导致这个确切的问题。

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.还要确保您删除了同一目录中的 libcloud.pyc 文件。

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.发生的事情是 python 认为您的 libcloud.py 文件是您要导入的 libcloud,这显然不起作用,因为您没有定义计算等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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