我只能在特定版本的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 上运行
I use Webfaction, and this is the command line for the shared host.
[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
I know there must be a simple way to make it work in all version of Python. I would much appreciate any insight on how to make this work/the concept behind it.
My version of Django runs on 2.7, so the goal is to make it work on 2.7
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的问题是
stripe
模块并未安装在每个 python 环境中。您必须在每个环境中安装
stripe
。根据您的网站主机,您应该能够使用easy_install
安装它们。试试这个:Your problem is that the
stripe
module is not installed in each python environment.You must install
stripe
in each environment. According to your webhost, you should be able to install them witheasy_install
. Try this:Brian Cain 关于它没有安装在您正在使用的 Python 版本中的说法是正确的。您应该运行以下命令,而不是执行他给出的命令:
在确保目录:
/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
在您的帐户上安装您自己的curl版本。
Brian Cain is correct about it not being installed in the Python version you are using. Instead of the command he gave you should run:
After making sure that the directory:
/home/username/lib/python2.7/
actually exists. If it doesn't you can use the command:mkdir -p /home/username/lib/python2.7
to create it.That will install it in your Python2.7 installation, which you can then use from Django on Python2.7.
Note: If you get the error: "Need libcurl version 7.19.0 or greater to compile pycurl." you'll need to follow the instructions here:
http://community.webfaction.com/questions/6365/problems-installing-pycurl
to install your own version of curl on your account.