在终端编译python和在emacs编译python怎么有点不对

我在做一些练习,这是我的文件

from sklearn.datasets import fetch_20newsgroups
from sklearn.model_selection import train_test_split
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.naive_bayes import MultinomialNB
from sklearn.metrics import classification_report

# 数据抓取
news = fetch_20newsgroups(subset='all')

在终端下

(base) ➜  bayes python3 news.py
Traceback (most recent call last):
  File "news.py", line 1, in <module>
    from sklearn.datasets import fetch_20newsgroups
ModuleNotFoundError: No module named 'sklearn'

在emacs下


用了virtualenv或者其它类似的东西吧。然后emacs的python-mode或者其它mode自动处理了环境变量,把python lib path自动加入了

没有诶

(base) ➜  bayes ls -a  
.  ..  news.py

那你在ielm里用getenv获取一下PYTHONPATH和类似的变量(也可以在python的解释环境里用sys.path ),还有在终端里看看。还有就是emacs里python-shell-exec-path这些。

要是这样还找不出原因,我没什么思路了