ipython从.pyenv而不是在虚拟环境内部导入内置

时间:2020-05-21 18:13:20

标签: python ipython pythonpath pyenv

我试图找出文件在Python虚拟环境中的位置。我正在关注this answerHow to retrieve a module's path?

我使用ipython运行以下代码来测试内置模块的位置:

In [1]: import logging

In [2]: logging.__file__
Out[2]: '/Users/some_user/.pyenv/versions/3.6.5/lib/python3.6/logging/__init__.py'

为什么__file__属性指向.pyenv目录中的文件而不是虚拟环境中的文件?


背景/版本

我有以下版本:

python==3.6.5 (inside venv)
python==3.7.6 (outside venv)
ipython==7.14.0 (inside venv)
ipython==7.13.0 (outside venv)

我这样调用ipython/path/to/venv/bin/python -m IPython

Python 3.6.5 (default, Mar 10 2020, 12:09:24)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.14.0 -- An enhanced Interactive Python. Type '?' for help.

0 个答案:

没有答案