【问题标题】:Why pymongo doesn't work with python3 and it only works with python2为什么 pymongo 不适用于 python3,它只适用于 python2
【发布时间】:2011-10-06 20:09:56
【问题描述】:
user@ubuntu:~/Documents/MongoDB$ python2
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) 
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from pymongo import Connection
>>> 
user@ubuntu:~/Documents/MongoDB$ python3
Python 3.1.2 (r312:79147, Sep 27 2010, 09:45:41) 
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from pymongo import Connection
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named pymongo

问题>我不知道为什么 pymongo 不能与我的 python 3 一起使用。有什么想法吗?

// 根据以下帮助更新此 OP 的解决方案 //

首先,还是不明白为什么这篇文章被否决了!

Step1> http://pypi.python.org/pypi/pymongo3#downloads

Step2> 下载pymongo3-1.9b1.tar.gz

Step3> 使用 tar xzf pymongo3-1.9b1.tar.gz 解压

Step4> cd pymongo3-1.9b1

Step5> sudo python3 setup.py install

如果您按照上述所有说明操作,pymongo 应该已经准备就绪 为你的 P3:)

【问题讨论】:

    标签: python mongodb ubuntu-10.04 pymongo


    【解决方案1】:

    可能是因为您没有为 Python 3 安装它。您必须为您拥有的每个 Python 版本安装一个模块才能从该版本访问它。这一切都假设该模块与每个版本兼容你拥有的 Python。

    【讨论】:

    • 你还需要一个不同的 Python 3 包:pypi.python.org/pypi/pymongo3
    • 链接已失效。无论如何,正如@Rafe Kettler 所说,您需要python3 mongodb。在 Ubuntu 中使用:pip3 install [package-name] 安装 p3 包。仅使用 pip install 将默认安装 p2 包。
    猜你喜欢
    • 2019-12-23
    • 2021-04-09
    • 1970-01-01
    • 1970-01-01
    • 2019-06-04
    • 2017-05-08
    • 2021-04-08
    • 1970-01-01
    • 2013-06-23
    相关资源
    最近更新 更多