我只能在特定的Python版本下导入Stripe Python库

我使用Webfaction,这是共享主机的命令行。

[zallarak@web198 ~]$ python2.6 Python 2.6.5 (r265:79063, Nov 23 2010, 02:02:03) [GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import stripe >>> [zallarak@web198 ~]$ python2.7 Python 2.7.1 (r271:86832, Dec 1 2010, 06:29:57) [GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import stripe Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named stripe 

我知道必须有一个简单的方法才能在所有版本的Python中工作。 我非常感谢任何有关如何使这项工作/背后的概念。

我的Django版本运行在2.7,所以目标是使它在2.7上工作

你的问题是stripe模块没有安装在每个python环境中。

我知道必须有一个简单的方法才能在所有版本的Python中工作。

您必须在每个环境中安装stripe 。 根据你的虚拟主机 ,你应该可以用easy_install来安装它们。 尝试这个:

 python2.7 `which easy_install` stripe 

Brian Cain是正确的,它没有被安装在你正在使用的Python版本中。 他给你的命令应该运行:

 easy_install-2.7 stripe 

确保目录: /home/username/lib/python2.7/确实存在后。 如果没有,您可以使用命令: mkdir -p /home/username/lib/python2.7来创建它。

这将安装在您的Python2.7安装中,然后您可以在Python2.7上使用Django。

注意:如果出现错误:“需要libcurl版本7.19.0或更高版本才能编译pycurl”。 你需要按照这里的说明:

http://community.webfaction.com/questions/6365/problems-installing-pycurl

在您的帐户上安装您自己的卷发版本。