为什么在python的本地virtualenv版本中没有安装json模块?

2024-05-19 00:21:26 发布

您现在位置:Python中文网/ 问答频道 /正文

我创建了python的一个新的本地virtualenv版本,并执行了以下操作以查看运行的json副本。由于某些原因,正在运行的版本不是新创建的virtualenv版本。有人能解释一下吗?我希望我的virtualenv是一个全新的拷贝,它与系统范围的拷贝无关,特别是因为我用--no-site-packages标志运行它。在

(TEST) GBMAC0122 ~/Desktop/test $ virtualenv . --no-site-packages
New python executable in /Users/jonathan/Desktop/test/bin/python
Installing setuptools, pip, wheel...done.
(TEST) GBMAC0122 ~/Desktop/test $ source bin/activate
(test) GBMAC0122 ~/Desktop/test $ python
Python 2.7.10 (default, Feb  7 2017, 00:08:15) 
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import json
>>> json.__file__
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.pyc'

Tags: notest版本jsonbinvirtualenvpackages系统
1条回答
网友
1楼 · 发布于 2024-05-19 00:21:26

no-site-packages(现在是默认行为)指示virtualenv给每个新环境一个新的site-packages,这是安装新的模块的地方。复制json这样的内置模块没有任何意义,因为无论您所处的环境如何,都假定内置模块是未被触及的。你不应该一开始就改变他们。在

有趣的是,virtualenv必须将a few builtin modules复制到{a2}。在

相关问题 更多 >

    热门问题