我创建了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'
no-site-packages
(现在是默认行为)指示virtualenv
给每个新环境一个新的site-packages
,这是安装新的模块的地方。复制json
这样的内置模块没有任何意义,因为无论您所处的环境如何,都假定内置模块是未被触及的。你不应该一开始就改变他们。在有趣的是,
virtualenv
必须将a few builtin modules复制到{a2}。在相关问题 更多 >
编程相关推荐