最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】VSCode中的Jupyter的notebook已切换当前Python版本后但还是报错ModuleNotFoundError

VSCode crifan 478浏览 0评论
折腾:
【未解决】VSCode中调试Notebook的ipynb文件中的Python代码
期间,重新打开:Jizhi_chap3.ipynb
然后以为就没有报缺少库的错了,以及server也正常了,结果还是有问题:
结果点击后,还是缺少库:
ModuleNotFoundError             Traceback (most recent call last) in
      1 import numpy as np
----> 2 import pandas as pd

ModuleNotFoundError: No module named 'pandas'
去安装:
➜  ~ pip install pandas
Looking in indexes: 
http://mirrors.aliyun.com/pypi/simple/
Requirement already satisfied: pandas in ./.pyenv/versions/3.7.3/lib/python3.7/site-packages (1.0.1)
Requirement already satisfied: numpy>=1.13.3 in ./.pyenv/versions/3.7.3/lib/python3.7/site-packages (from pandas) (1.18.1)
Requirement already satisfied: python-dateutil>=2.6.1 in ./.pyenv/versions/3.7.3/lib/python3.7/site-packages (from pandas) (2.8.1)
Requirement already satisfied: pytz>=2017.2 in ./.pyenv/versions/3.7.3/lib/python3.7/site-packages (from pandas) (2019.3)
Requirement already satisfied: six>=1.5 in ./.pyenv/versions/3.7.3/lib/python3.7/site-packages (from python-dateutil>=2.6.1->pandas) (1.14.0)
已安装过了啊。
发现,此处的notebook的python版本,也要点击去切换:
切换后,在确认看看:
终于,点击第一个运行按钮后,不再报错了:
 
【总结】
此处,已经用pyenv安装和设置了全局python 3.7.3
且给python 3.7.3安装了相关的:Jupyter、notebook、numpy、pandas等库
且VSCode中也已切换到对应python了
结果点击运行还是报错:ModuleNotFoundError
原因:此处的Jupyter中(server端?)也要设置(选择)python版本:
才可以找到对应python,正常运行代码。

转载请注明:在路上 » 【已解决】VSCode中的Jupyter的notebook已切换当前Python版本后但还是报错ModuleNotFoundError

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
87 queries in 0.142 seconds, using 20.73MB memory