https://stackoverflow.com/a/32474751/5089204。如果在运行pip时它们的依赖项可用,则会安装它们;否则没有。
事后,如何判断给定pip包的C扩展是在系统级还是在给定的virtualenv中?
虽然pymongo是我目前关注的问题,但如果存在任意包的方法,我会很高兴。
答案 0 :(得分:0)
可能有一个更优雅的解决方案,但你可以先用pip找到你机器上文件的位置:
vagrant@devboxM:~$ pip show pymongo
---
Metadata-Version: 2.0
Name: pymongo
Version: 3.2.2
Summary: Python driver for MongoDB <http://www.mongodb.org>
Home-page: http://github.com/mongodb/mongo-python-driver
Author: Bernie Hackett
Author-email: bernie@mongodb.com
Installer: pip
License: Apache License, Version 2.0
Location: /opt/miniconda2/lib/python2.7/site-packages
Requires:
Classifiers:
....
然后,您可以转到指定的目录并查看是否有任何已编译的库:
vagrant@devboxM:~$ cd /opt/miniconda2/lib/python2.7/site-packages/pymongo
vagrant@devboxM:/opt/miniconda2/lib/python2.7/site-packages/pymongo$ ls
auth.py database.py monitoring.pyc response.py ssl_context.pyc
auth.pyc database.pyc monitor.py response.pyc ssl_match_hostname.py
bulk.py errors.py monitor.pyc results.py ssl_match_hostname.pyc
bulk.pyc errors.pyc monotonic.py results.pyc ssl_support.py
client_options.py helpers.py monotonic.pyc server_description.py ssl_support.pyc
client_options.pyc helpers.pyc network.py server_description.pyc thread_util.py
_cmessage.so __init__.py network.pyc server.py thread_util.pyc
collection.py __init__.pyc operations.py server.pyc topology_description.py
collection.pyc ismaster.py operations.pyc server_selectors.py topology_description.pyc
command_cursor.py ismaster.pyc periodic_executor.py server_selectors.pyc topology.py
command_cursor.pyc message.py periodic_executor.pyc server_type.py topology.pyc
common.py message.pyc pool.py server_type.pyc uri_parser.py
common.pyc mongo_client.py pool.pyc settings.py uri_parser.pyc
cursor_manager.py mongo_client.pyc read_concern.py settings.pyc write_concern.py
cursor_manager.pyc mongo_replica_set_client.py read_concern.pyc son_manipulator.py write_concern.pyc
cursor.py mongo_replica_set_client.pyc read_preferences.py son_manipulator.pyc
cursor.pyc monitoring.py read_preferences.pyc ssl_context.py
如果您看到一个已编译的库 - 这是一个Linux框,所以在这种情况下它是_cmessage.so
,但是不同的平台有不同的约定 - 那么它很可能至少再次编译一些的C扩展。