jupyter notebook 导入已经在pycharm里pip install过的包报错

1. 问题描述

🐱: 当我每天都在cmd/Terminal等地方pip install我的python lib时,打开Jupyter notebook 发现,有一些包明明在电脑里有,比如torch, searborn之类的,在jupyter notebook 里import 对应包确报错,找不到这些包

2. 处理方法

🔵查看平时pip install 的lib文件目录

在jupyter notebook 的cell里面输入:

python 复制代码
import site
site.getsitepackages()

🟡运行上面代码,得到输出,将输出的类似于python\lib\site-packages这个文件目录添加到当前系统文件夹

python 复制代码
import sys
sys.path.append('D:\\Program Files\\Python3.64\\Lib\\site-packages')

🟠再次导入报错的包,发现不再报错


Jupyter Notebook 常用import

python 复制代码
# Ignore future warnings from pandas
import warnings
warnings.filterwarnings('ignore')

# Required libraries
# Importing the libraries
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
plt.style.use('fivethirtyeight')
matplotlib.rcParams['font.sans-serif']=['SimHei']   # 用黑体显示中文
相关推荐
木头左5 小时前
HMM隐马尔可夫模型在指数期权双币种套利策略
python
@zulnger5 小时前
Django 框架(django-admin 命令详解)
python·django
_Johnny_5 小时前
【API Echo】API测试回调工具 - 回显请求内容
python·flask·api
知乎的哥廷根数学学派5 小时前
基于物理约束指数退化与Hertz接触理论的滚动轴承智能退化趋势分析(Pytorch)
开发语言·人工智能·pytorch·python·深度学习·算法·机器学习
Ethan Hunt丶5 小时前
基于Pytorch预训练模型实现声纹识别系统
人工智能·pytorch·python·语音识别
张小凡vip5 小时前
数据挖掘(二) ----- Jupyter Notebook使用示例和常见问题
人工智能·jupyter·数据挖掘
Katecat996635 小时前
【铁路检测】YOLO11-C3k2-StripCGLU模型在铁路轨道缺陷检测中的应用与改进
python
理想是做全栈工程师5 小时前
基于UNet的带噪黑白数字图像分割模型
人工智能·pytorch·python·anaconda
lbb 小魔仙5 小时前
从零搭建 Spring Cloud 微服务项目:注册中心 + 网关 + 配置中心全流程
java·python·spring cloud·微服务