[英]No module named ___. How to link Sublime Text3 to a virtual env in python 3?
I suppose my sublime text 3 does not see the venv.我想我的崇高文本 3 没有看到 venv。
I've set up a virtual environment on python 3 via venv.我已经通过 venv 在 python 3 上设置了一个虚拟环境。 I work in Sublime text 3 on Mac.我在 Mac 上使用 Sublime text 3。
When I tried to import non built-in modules like yaml or any other in Sublime I got an error : ImportError: No module named yalm.当我尝试在 Sublime 中导入非内置模块(如 yaml 或任何其他模块)时,出现错误:ImportError: No module named yalm。 However, the module is properly installed with pip.但是,该模块已通过 pip 正确安装。 The venv is activated. venv 被激活。 I even launch Sublime with the "subl" command from terminal.我什至从终端使用“subl”命令启动 Sublime。
running this运行这个
import json
import numpy
import sys
import requests
print('\n'.join(sys.path))
I get:我得到:
/Users/maksim/Desktop/py_exercise/code /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload
/Library/Python/2.7/site-packages
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC
/Users/maksim/Desktop/py_exercise/code
is my working directory with the venv inside. /Users/maksim/Desktop/py_exercise/code
是我的工作目录,里面有 venv。 And numpy is not installed in my venv.我的 venv 中没有安装 numpy。
When I run python in the shell from terminal, it finds modules easily.当我从终端在 shell 中运行 python 时,它很容易找到模块。 I also have anaconda installed on my machine.我的机器上也安装了 anaconda。
How to link sublime3 to an active virtual env?如何将 sublime3 链接到活动的虚拟环境? What is the best practise of that?最好的做法是什么?
A good option is to launch your terminal, activate your environment (venv), and then launch sublime from that prompt一个不错的选择是启动您的终端,激活您的环境(venv),然后从该提示启动 sublime
$ source venv/bin/activate
(venv)$ subl .
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.