当我尝试实例化 MongoClient 时,pymongo(版本 3.6.0)出现错误。我的 Python 版本是 3.7.4,在 OS X Mojave 上运行。
有人知道如何解决这个问题或者是否有任何解决方法?
$ pip3 freeze | grep pymongo
WARNING: Could not generate requirement for distribution -ppnope 0.1.0 (/usr/local/lib/python3.7/site-packages): Parse error at "'-ppnope='": Expected W:(abcd...)
pymongo==3.6.0
---------------------------------------------------------------------------
LookupError Traceback (most recent call last)
<ipython-input-69-60edd7a153e2> in <module>
----> 1 import pymongo
2
3 client = pymongo.MongoClient("mongodb://XXXXXX:27017")
4
/usr/local/lib/python3.7/site-packages/pymongo/__init__.py in <module>
79 MAX_SUPPORTED_WIRE_VERSION)
80 from pymongo.cursor import CursorType
---> 81 from pymongo.mongo_client import MongoClient
82 from pymongo.mongo_replica_set_client import MongoReplicaSetClient
83 from pymongo.operations import (IndexModel,
/usr/local/lib/python3.7/site-packages/pymongo/mongo_client.py in <module>
51 uri_parser,
52 client_session)
---> 53 from pymongo.client_options import ClientOptions
54 from pymongo.command_cursor import CommandCursor
55 from pymongo.cursor_manager import CursorManager
/usr/local/lib/python3.7/site-packages/pymongo/client_options.py in <module>
21 from pymongo.errors import ConfigurationError
22 from pymongo.monitoring import _EventListeners
---> 23 from pymongo.pool import PoolOptions
24 from pymongo.read_concern import ReadConcern
25 from pymongo.read_preferences import (make_read_preference,
/usr/local/lib/python3.7/site-packages/pymongo/pool.py in <module>
245 # to import the IDNA codec. Import it here, where presumably we're on the
246 # main thread, to avoid the deadlock. See PYTHON-607.
--> 247 u'foo'.encode('idna')
248
249
LookupError: unknown encoding: idna