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']   # 用黑体显示中文
相关推荐
凡人的AI工具箱几秒前
15分钟学 Python 第38天 :Python 爬虫入门(四)
开发语言·人工智能·后端·爬虫·python
码农超哥同学11 分钟前
Python知识点:在Python编程中,如何使用Gensim进行主题建模
开发语言·python·面试·编程
奔跑吧邓邓子15 分钟前
JSON 全知全解:深入探索 JSON 的奥秘
开发语言·python·json
theoxiong32 分钟前
深度解析:Tkinter 界面布局与优化技巧
python·ui·pyqt·tkinter
背水1 小时前
pytorch数据读入
人工智能·pytorch·python
Ambition_LAO1 小时前
不同版本的 Selenium 和 WebDriver 的 API 兼容性问题
开发语言·python
xs_20121 小时前
Python selenium库学习使用实操二
python·学习·selenium
worxfr1 小时前
Python Selenium常用语法汇总(包含XPath语法)
开发语言·python·selenium·xpath
MicrosoftReactor2 小时前
技术速递|Python in Visual Studio Code 2024年9月发布
vscode·python·jupyter
想七想八不如114082 小时前
【OpenCV】 Python 图像处理 入门
图像处理·python·opencv