2014-11-06 80 views
0

背景資料:試圖安裝在Ubuntu 12.04 pymongo

您好。我試圖讓MongoDB和Python(2.7.8)在我的Ubuntu 12.04盒子上工作。 我已經安裝並運行了mongodb ... 我認爲我也設置了python。現在我正在嘗試安裝pymongo。

問題

當我嘗試安裝pymongo,這是我得到:

[email protected]:~/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 
[email protected]:~/Documents/Python-2.7.8$ 

日誌文件pip.log看起來是這樣的:基於日誌http://pastebin.com/15wv38kf

,tt *好像我需要更新存儲庫以在不同的URL中查找軟件包......但我不確定要添加哪個庫/網址。

其他的事情我已經測試/檢查:

檢索更新軟件包列表:

sudo apt-get update 

證明了Python 2.7.8安裝:

[email protected]:~/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已安裝:

[email protected]:~/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) 
[email protected]:~/Documents/Python-2.7.8$ 

事實證明,MongoDB是安裝(但顯然不是正確安裝!):

[email protected]:~/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 
[email protected]:~/Documents/Python-2.7.8$ 

任何建議,將不勝感激。

編輯1

我試着只是用包管理器的建議安裝,但似乎並沒有工作。請看結果在:http://pastebin.com/V56KXzFT

也許我的測試證明pymongo安裝是錯誤的?

EDIT 2

我現在不記得,但我認爲Ubuntu默認12.0.4與Python 2.7.3或類似的東西。但我正在學習一門課,它需要2.7.8。 起初,我下載了一個壓縮文件的Python 2.7.6,在我的文檔文件夾中保存它...
我是解壓並運行

./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

這可能與問題有關嗎?

+0

如果點子是給你一個困難時期,儘量只通過Debian軟件包使用'sudo apt-get的安裝python-pymongo'安裝。 – CasualDemon 2014-11-06 14:10:05

+0

@CasualDemon,感謝您的幫助。請在後期看到我的編輯1 ...它沒有工作。 – dot 2014-11-06 14:13:59

+0

你在虛擬環境中工作嗎?如果它是'virtualenv --system-site-packages',你將不得不使用繼承的包創建它。 – CasualDemon 2014-11-06 14:20:26

回答

1

「點子安裝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... 

我猜它沒有你,因爲,也許,你首先必須升級「點子」本身。

我注意到你已經嘗試安裝PyMongo的各種方法,有些方法的工作,但是當你在Python做「進口pymongo」失敗。在這裏,我想你已經安裝了多個版本的Python,並且你的默認Python與PyMongo的系統Python不同。

+0

你好!感謝您試圖幫助。所以curl命令不會返回任何東西。沒有錯誤,沒有任何東西。我只是立即讓我的命令提示符回來。但我想對http://www.google.ca捲曲和我被人拋棄我的屏幕上的網頁... – dot 2014-11-06 19:58:57

+0

這似乎是這個問題是與URL的「pymongo」的一部分......因爲當我這樣做一個「捲曲https://pypi.python.org/simple」..它的作品。也許我需要指定哪個版本,當我做pip安裝pymongo? – dot 2014-11-06 20:06:30

+0

嗯。 PyMongo對我來說安裝得很好: – 2014-11-06 20:55:07