pip3 install pymongo
image.png
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting pymongo
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pymongo/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pymongo/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pymongo/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pymongo/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pymongo/
Could not fetch URL https://pypi.org/simple/pymongo/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pymongo/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
ERROR: Could not find a version that satisfies the requirement pymongo (from versions: none)
ERROR: No matching distribution found for pymongo
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
这是由于网络的问题,那么就换一个国内的镜像源头
pip3 install pymongo -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
提示如下,下载是下载成功了,但是提示么有权限无法按照
Looking in indexes: http://pypi.douban.com/simple/
Collecting pymongo
Downloading http://pypi.doubanio.com/packages/70/6d/a8da5563d9ca8cfe4786ce3aa6a74d6ab6acd2e489a842e67f070db043d4/pymongo-3.10.0-cp38-cp38-manylinux1_x86_64.whl (464kB)
|████████████████████████████████| 471kB 17.9MB/s
Installing collected packages: pymongo
ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/usr/local/lib/python3.8/site-packages/pymongo'
Consider using the `--user` option or check the permissions.
WARNING: You are using pip version 19.2.3, however version 19.3.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
可以看到上面的错误提示中有提示 加--user,试一下
pip3 install pymongo -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com --user
安装成功
Looking in indexes: http://pypi.douban.com/simple/
Collecting pymongo
Downloading http://pypi.doubanio.com/packages/70/6d/a8da5563d9ca8cfe4786ce3aa6a74d6ab6acd2e489a842e67f070db043d4/pymongo-3.10.0-cp38-cp38-manylinux1_x86_64.whl (464kB)
|████████████████████████████████| 471kB 16.6MB/s
Installing collected packages: pymongo
Successfully installed pymongo-3.10.0
WARNING: You are using pip version 19.2.3, however version 19.3.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
最开始提示没有模块
image.png
安装成功后,程序运行出来
程序代码:
#!/usr/bin/python3
import pymongo
myclient = pymongo.MongoClient('mongodb://localhost:27017/')
dblist = myclient.list_database_names()
print(dbliist)
结果:
python3 test_mogondb.py
['admin', 'config', '20190909', 'local']
网友评论