我需要我的程序表现不同,具体取决于输出是终端还是文件.如何在C++中找到它?
我假设没有适用于所有操作系统的解决方案.为了我的目的,最好有一个在Windows下工作的策略和一个在linux/unix下工作的策略.
提前致谢.
我可以在从 bash 运行 python 或 ipython 时导入 nltk 包。所以,nltk 肯定安装在某个地方(在 bash 的 python 中,
nltk.__file__是
/home/nadine/anaconda2/lib/python2.7/site-packages/nltk/__init__.pyc)
但是,当使用 Jupyter Notebook(我使用 Anaconda 安装,使用 2.7 版本的 python)时,导入 nltk 失败:
import nltk
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-2-b06499430ee0> in <module>()
----> 1 import nltk
ImportError: No module named nltk
Run Code Online (Sandbox Code Playgroud)
在 Jupyter Notebook 中,sys.executableyields /home/nadine/.conda/envs/py27/bin/python,而在 bash 中的 python 中,它产生/home/nadine/anaconda2/bin/python2.7
这里到底出了什么问题,我该如何解决?