如果我在Ubuntu16.04 (Python2)上创建了一个虚拟环境,那么就会创建一个包含符号链接的local目录:
===> virtualenv symlinktest
New python executable in /home/tguettler/tmp/symlinktest/bin/python
Please make sure you remove any previous custom paths from your /home/tguettler/.pydistutils.cfg file.
Installing setuptools, pip, wheel...done.
===> ls -l symlinktest/local/
===> ls -l symlinktest/local/*
lrwxrwxrwx 1 tguettler tguettler 35 Mär 7 14:21 symlinktest/local/bin -> /home/tguettler/tmp/symlinktest/bin
lrwxrwxrwx 1 tguettler tguettler 39 Mär 7 14:21 symlinktest/local/include -> /home/tguettler/tmp/symlinktest/include
lrwxrwxrwx 1 tguettler tguettler 35 Mär 7 14:21 symlinktest/local/lib -> /home/tguettler/tmp/symlinktest/lib
===> virtualenv --version
15.0.3这在其他linux发行版上不会发生。
为什么要在哪里创建这个符号链接?
更新
在这个平台上,创建了一个从lib64到openSUSE 42.1 (x86_64)的符号链接...
我不明白为什么需要这个符号链接。
发布于 2017-03-09 19:47:49
因此,在稍微研究了一下virtualenv代码之后,似乎发生了以下情况:
create_environment调用install_python,后者调用fix_local_scheme (https://github.com/pypa/virtualenv/blob/master/virtualenv.py#L1492)。注意他们是如何在文档字符串中声明这是posix系统所需要的,比如Ubuntu with Python2.7(您正在运行的)
>>> import platform
>>> platform.linux_distribution()
('Ubuntu', '16.04', 'xenial')
$ python2.7
Python 2.7.12 (default, Nov 19 2016, 06:48:10)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sysconfig
>>> sysconfig._get_default_scheme()
'posix_local'
$ cat /usr/lib/python2.7/sysconfig.py
def _get_default_scheme():
if os.name == 'posix':
# the default scheme for posix on Debian/Ubuntu is posix_local
# FIXME: return dist-packages/posix_prefix only for
# is_default_prefix and 'PYTHONUSERBASE' not in os.environ and 'real_prefix' not in sys.__dict__
# is_default_prefix = not prefix or os.path.normpath(prefix) in ('/usr', '/usr/local')
return 'posix_local'
return os.name您还可以阅读关于不同前缀的解释:https://pymotw.com/2/sysconfig/#installation-paths,以了解更多信息。
https://stackoverflow.com/questions/42649515
复制相似问题