试图在ubuntu 12.04上安装pymongo

时间:2014-11-06 13:38:22

标签: mongodb python-2.7 ubuntu-12.04 pip

背景资料:

你好。我试图让mongodb和python(2.7.8)在我的ubuntu 12.04盒子上工作。 我安装并运行了mongodb ...... 我认为我也设置了python。现在我正在尝试安装pymongo。

问题

当我尝试安装pymongo时,这就是我得到的:

me@mydev:~/Documents/Python-2.7.8$ pip install pymongo
Downloading/unpacking pymongo
  Cannot fetch index base URL http://pypi.python.org/simple/
  Could not find any downloads that satisfy the requirement pymongo
No distributions at all found for pymongo
Storing complete log in /home/me/.pip/pip.log
me@mydev:~/Documents/Python-2.7.8$ 

日志文件pip.log如下所示:http://pastebin.com/15wv38kf

基于日志,tt *似乎我需要更新存储库以在不同的URL中查找包...但我不确定要添加的库/ URL。

我测试/检查的其他事项:

检索更新的包列表:

sudo apt-get update

证明安装了python 2.7.8:

me@medev:~/Documents/Python-2.7.8$ python
Python 2.7.8 (default, Nov  5 2014, 15:18:10) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 

证明已安装PIP:

me@medev:~/Documents/Python-2.7.8$ pip
Usage: pip COMMAND [OPTIONS]

pip: error: You must give a command (use "pip help" to see a list of commands)
me@medev:~/Documents/Python-2.7.8$ 

证明安装了mongodb(但显然设置不正确!):

me@medev:~/Documents/Python-2.7.8$ mongo
MongoDB shell version: 2.6.5
connecting to: test
2014-11-06T08:23:47.444-0500 warning: Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2014-11-06T08:23:47.444-0500 Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed at src/mongo/shell/mongo.js:146
exception: connect failed
me@medev:~/Documents/Python-2.7.8$ 

任何建议将不胜感激。

编辑1

我尝试按照建议使用软件包管理器进行安装,但这似乎不起作用。请在以下位置查看结果:http://pastebin.com/V56KXzFT

也许我的测试证明pymongo安装是错误的?

编辑2

我现在无法记住,但我认为默认情况下Ubuntu 12.0.4附带python 2.7.3或类似的东西。但是我做了一门课程,需要2.7.8。 最初,我下载了一个用于python 2.7.6的zip文件,并将其保存在我的Documents文件夹中...... 我解压缩并运行

./compile
make
make install
然后我意识到我需要2.7.8,所以我做了同样的事情。下载了zip ...和 编译。 这是我用作安装2.7.8的参考的链接: https://askubuntu.com/questions/101591/how-do-i-install-python-2-7-2-on-ubuntu

这可能与此问题有关吗?

1 个答案:

答案 0 :(得分:1)

“pip install pymongo”在我的Linux机箱上正常工作:

$ sudo pip install pymongo
Downloading/unpacking pymongo
  Downloading pymongo-2.7.2.tar.gz (381kB): 381kB downloaded
  Running setup.py (path:/tmp/pip_build_root/pymongo/setup.py) egg_info for package pymongo

Installing collected packages: pymongo
  Running setup.py install for pymongo
    building 'bson._cbson' extension
    gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Ibson -I/usr/local/include/python2.7 -c bson/_cbsonmodule.c -o build/temp.linux-x86_64-2.7/bson/_cbsonmodule.o
    gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Ibson -I/usr/local/include/python2.7 -c bson/time64.c -o build/temp.linux-x86_64-2.7/bson/time64.o
    gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Ibson -I/usr/local/include/python2.7 -c bson/buffer.c -o build/temp.linux-x86_64-2.7/bson/buffer.o
    gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Ibson -I/usr/local/include/python2.7 -c bson/encoding_helpers.c -o build/temp.linux-x86_64-2.7/bson/encoding_helpers.o
    gcc -pthread -shared -Wl,-rpath /usr/local/lib build/temp.linux-x86_64-2.7/bson/_cbsonmodule.o build/temp.linux-x86_64-2.7/bson/time64.o build/temp.linux-x86_64-2.7/bson/buffer.o build/temp.linux-x86_64-2.7/bson/encoding_helpers.o -L/usr/local/lib -lpython2.7 -o build/lib.linux-x86_64-2.7/bson/_cbson.so
    building 'pymongo._cmessage' extension
    < ... snip ... >

Successfully installed pymongo
Cleaning up...

我猜你失败了,因为也许你首先必须升级“pip”本身。

我注意到你已经尝试了各种安装PyMongo的方法,有些方法可以工作,但是当你在Python中“导入pymongo”时它会失败。在这里,我想您已经安装了多个版本的Python,并且您的默认Python与安装了PyMongo的系统Python不同。