2021-01-26

本文介绍了解决Jupyter中加载TensorFlow遇到的问题的方法,包括生成notebook配置文件、设置密码、修改配置文件等内容,并提供了卸载和重新安装Jupyter的详细步骤。

在jupyter中无法加载tensorflow的解决方案/

1.创建key的步骤如下:

step1 : 生成一个 notebook 配置文件: jupyter notebook --generate-config
step2 :生成密码:jupyter notebook password
jupyter notebook password
Enter password: ****
Verify password: ****
[NotebookPasswordApp] Wrote hashed password to /Users/you/.jupyter/jupyter_notebook_config.json

step3 :修改配置文件 jupyter_notebook_config.py
c.NotebookApp.ip=’*’
c.NotebookApp.password = u’sha:ce…刚才复制的那个密文’
c.NotebookApp.open_browser = False
c.NotebookApp.port =8888 #可自行指定一个端口, 访问时使用该端口
2.在虚拟换环境tensorflow中安装jupyter
python3 -m pip install --upgrade pip
python3 -m pip install jupyter
3.在tensorflow敲jupyter notebook,打开jupyter,默认火狐浏览器,端口8888

出现问题: 在虚拟换环境tensorflow中已经安装了jupyter,仍然不能加载。可能jupyter和tensorflow环境不匹配,需要重新安装jupyter。
卸载jupyter的方法:
1.知乎方法:
Mark 一下Ubuntu 16.04下卸载 jupyter notebook(并非Anaconda安装),希望能帮到大家
打开终端:输入一下命令
sudo python3.6 -m pip uninstall jupyter

sudo python3.6 -m pip uninstall jupyter_core

sudo python3.6 -m pip uninstall jupyter-client

sudo python3.6 -m pip uninstall jupyter-console

sudo python3.6 -m pip uninstall notebook

sudo python3.6 -m pip uninstall qtconsole

sudo python3.6 -m pip uninstall nbconvert
此方法不通
2.卸载
使用pip uninstall jupyter是卸不掉jupyter的

1.(virenv)~/ pip install pip-autoremove
2.(virenv)~/ pip-autoremove jupyter -y

pip-autoremove会卸载掉package和无用的依赖
此法为尝试过。
3敲命令行
conda remove jupyter*
此方法可行
重新安装jupyter

1.在tensorflow虚拟环境中运行 jupyter notebook
有信息
[W 22:37:01.172 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using encryption. This is not recommended.
[I 22:37:01.194 NotebookApp] Serving notebooks from local directory: /home/max
[I 22:37:01.195 NotebookApp] The Jupyter Notebook is running at:
[I 22:37:01.195 NotebookApp] http://(max-virtual-machine or 127.0.0.1):8888/
[I 22:37:01.195 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
此时,在火狐浏览器输入
http://localhost:8888即可进入

在windows浏览器上登陆方法:
找到虚拟机ip,此处192.168.171.133,端口设为8888

http://192.168.171.133:8888/
即可

你提供的数据是一个典型的空气质量监测数据集,包含日期、AQI 和多种污染物浓度以及污染等级。我们可以基于此数据进行统计分析、可视化或模型训练等操作。 以下是一些可以执行的常见任务和示例代码: --- ### ✅ 1. 数据加载与查看 ```python import pandas as pd # 假设你的数据存储在一个 CSV 文件中 data = pd.read_csv("air_quality_data.csv") # 查看前几行数据 print(data.head()) ``` --- ### ✅ 2. 按污染等级分组统计污染物均值 ```python grouped_stats = data.groupby('污染等级').agg({ 'PM2.5': 'mean', 'PM10': 'mean', 'CO': 'mean', 'NO2': 'mean', 'SO2': 'mean', 'O3_8h': 'mean' }).reset_index() print(grouped_stats) ``` --- ### ✅ 3. 绘制箱线图(Boxplot)比较不同污染等级下的污染物分布 ```python import matplotlib.pyplot as plt import seaborn as sns pollutants = ['PM2.5', 'PM10', 'CO', 'NO2', 'SO2', 'O3_8h'] fig, axes = plt.subplots(2, 3, figsize=(16, 10), dpi=100) axes = axes.flatten() for i, pollutant in enumerate(pollutants): sns.boxplot(x='污染等级', y=pollutant, data=data, ax=axes[i], palette="Set2") axes[i].set_title(f'{pollutant} 分布') axes[i].tick_params(axis='x', rotation=45) plt.tight_layout() plt.show() ``` --- ### ✅ 4. 进行显著性检验(ANOVA 或 Kruskal-Wallis) ```python from scipy.stats import f_oneway, kruskal for pollutant in pollutants: groups = [group[pollutant].values for name, group in data.groupby('污染等级')] # 正态性检验(可选) normality_results = [stats.normaltest(group) for group in groups] p_values_normal = [p for stat, p in normality_results] if all(p > 0.05 for p in p_values_normal): f_stat, p_val = f_oneway(*groups) print(f"污染物 {pollutant}: ANOVA p-value = {p_val:.4f}") else: h_stat, p_val = kruskal(*groups) print(f"污染物 {pollutant}: Kruskal-Wallis p-value = {p_val:.4f}") ``` --- ###
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值