【mongodb】安裝pymongo
pymongo是一個驅動程式,用Python編寫的高效能,檔案為基礎的資料庫。
下載並安裝。
[mongodb@localhost bin]$ wget
--21:21:18--
正在解析主機 pypi.python.org... 82.94.164.168, 2001:888:2000:d::a8
Connecting to pypi.python.org|82.94.164.168|:80... 已連線。
已發出 HTTP 請求,正在等待回應... 200 OK
長度:146895 (143K) [application/x-gzip]
Saving to: `pymongo-1.9.tar.gz'
100%[============================================================================================>] 146,895 66.9K/s in 2.1s
21:21:21 (66.9 KB/s) - `pymongo-1.9.tar.gz' saved [146895/146895]
[mongodb@localhost bin]$ tar zxvf pymongo-1.9.tar.gz
pymongo-1.9/
pymongo-1.9/doc/
pymongo-1.9/ez_setup.py/
pymongo-1.9/pymongo/
pymongo-1.9/setup.cfg
pymongo-1.9/setup.py
......
pymongo-1.9/bson/timestamp.py
pymongo-1.9/bson/tz_util.py
[mongodb@localhost bin]$ cd pymongo-1.9
[mongodb@localhost pymongo-1.9]$ ls
bson ez_setup.py LICENSE PKG-INFO pymongo.egg-info setup.cfg test
doc gridfs MANIFEST.in pymongo README.rst setup.py tools
第一次執行安裝的時候報錯,許可權不夠
[mongodb@localhost pymongo-1.9]$ python setup.py install
running install
error: can't create or remove files in install directory
The following error occurred while trying to add or remove files in the
installation directory:
[Errno 13] Permission denied: '/usr/lib64/python2.4/site-packages/test-easy-install-11661.write-test'
The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:
/usr/lib64/python2.4/site-packages/
Perhaps your account does not have write access to this directory? If the
installation directory is a system-owned directory, you may need to sign in
as the administrator or "root" account. If you do not have administrative
access to this machine, you may wish to choose a different installation
directory, preferably one that is listed in your PYTHONPATH environment
variable.
以root許可權給monogdb賦予訪問/usr/lib64/python2.4/site-packages/的許可權:
[root@localhost ~]# chown monogdb:monogdb /usr/lib64/python2.4/site-packages/
再次安裝。。
[mongodb@localhost pymongo-1.9]$ python setup.py install
running install
running bdist_egg
running egg_info
writing pymongo.egg-info/PKG-INFO
writing top-level names to pymongo.egg-info/top_level.txt
writing dependency_links to pymongo.egg-info/dependency_links.txt
Processing pymongo-1.9-py2.4-linux-x86_64.egg
creating /usr/lib64/python2.4/site-packages/pymongo-1.9-py2.4-linux-x86_64.egg
Extracting pymongo-1.9-py2.4-linux-x86_64.egg to /usr/lib64/python2.4/site-packages
Adding pymongo 1.9 to easy-install.pth file
Installed /usr/lib64/python2.4/site-packages/pymongo-1.9-py2.4-linux-x86_64.egg
Processing dependencies for pymongo==1.9
Finished processing dependencies for pymongo==1.9
測試python環境中與monogdb的互動。
[mongodb@localhost pymongo-1.9]$ python
Python 2.4.3 (#1, Jan 21 2009, 01:11:33)
[GCC 4.1.2 20071124 (Red Hat 4.1.2-42)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pymongo
>>> conn = pymongo.Connection(host="127.0.0.1")
>>> db=conn.test
>>> db
Database(Connection('127.0.0.1', 27017), u'test')
>>> str={"id":1,'val':"hello monogdb"}
>>> db.test.save(str)
ObjectId('4e3fe5d8e138232e61000000')
>>> cursor = db.test.find()
>>> for i in cursor:
... print i
...
{u'_id': ObjectId('4e3fe5d8e138232e61000000'), u'id': 1, u'val': u'hello monogdb'}
>>>
成功!!
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/22664653/viewspace-704436/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- MongoDB Python官方驅動 PyMongo 的簡單封裝MongoDBPython封裝
- MongoDB 及 PyMongo 的基本用法MongoDB
- MongoDB和pymongo自用手冊MongoDB
- Python安裝PyMongo的方法詳細介紹PythonGo
- mongodb 安裝MongoDB
- 安裝mongodbMongoDB
- MAC 安裝 MongoDBMacMongoDB
- Docker安裝mongodbDockerMongoDB
- MongoDB | Linux 安裝MongoDBLinux
- 【mongodb安裝配置】MongoDB
- MongoDB的安裝MongoDB
- Ubuntu安裝和解除安裝mongodbUbuntuMongoDB
- ubuntu透過安裝包安裝MongodbUbuntuMongoDB
- docker-安裝mongodbDockerMongoDB
- 【MongoDB】安裝與配置MongoDB
- linux上安裝mongodbLinuxMongoDB
- Windows下安裝MongoDBWindowsMongoDB
- Mac下安裝MongodbMacMongoDB
- MongoDB安裝配置教程MongoDB
- win10 mongodb安裝教程_win10 mongodb安裝步驟Win10MongoDB
- docker安裝mongoDB及使用DockerMongoDB
- mac怎麼安裝mongodbMacMongoDB
- mongodb擴充套件安裝MongoDB套件
- MongoDB下載與安裝MongoDB
- CentOS7.7安裝mongodbCentOSMongoDB
- mongodb的安裝以及使用MongoDB
- MongoDB資料庫安裝MongoDB資料庫
- Mac 安裝與配置mongodbMacMongoDB
- MongoDB日常運維-02安裝MongoDB運維
- 如何在 Ubuntu 上安裝 MongoDBUbuntuMongoDB
- CentOS7.2 安裝 MongoDB 3.4CentOSMongoDB
- windows安裝mongodb詳細教程WindowsMongoDB
- 快速掌握mongoDB(一)——mongoDB安裝部署和常用shell命令MongoDB
- CentOS 7快速安裝Mongodb詳解CentOSMongoDB
- Homestead 安裝 MongoDB 以及擴充套件!MongoDB套件
- 如何安裝MongoDB併成功啟動MongoDB
- MongoDB基本介紹與安裝(1)MongoDB
- mongodb的安裝和啟動方法MongoDB
- mongodb macos 下的安裝和使用MongoDBMac