jupyter notebook 多环境conda kernel配置方式
作者:dby_freedom 时间:2022-09-05 04:45:36
一直记不住在jupyter notebook配置多环境编译器技巧,今总结于此,也希望对其他小伙伴有所帮助,如果有用请点赞!
1.对windows用户,win+R,输入cmd进去进入命令行,激活环境:
2.首先,确定自己是否安装包‘ipykernel',若是没有安装,则进行安装;已安装进行下一步。
3.然后输入命令:
python -m ipykernel install --user --name deeplearningproject --display-name "deeplearningproject"
注:上述两个 deeplearningproject,前者是自身环境名称,不能变化;后者是在jupyter notebook的显示名称,可修改。
4.至此,完成所有操作,输入jupyter notebook进行验证
5.大功告成
至此,完成所有操作。
补充知识:Python Jupyter notebook 运行 multiprocessing 跑不了的问题
最近工作中为了解决python支持多核cpu,遇到一个Jupyter notebook跑不了multiprocessing的问题。
网上找了些multiprocessing的例子,Pycharm可以跑,但是在Jupyter notebook上跑了就只有In[*],error log:
AttributeError: Can't get attribute 'task' on <module '__main__' <built-in>>
最后找到一个解决方案:把方法写到临时文件里,再读出来。
from multiprocessing import Pool
from functools import partial
import inspect
def parallal_task(func, iterable, *params):
with open(f'./tmp_func.py', 'w') as file:
file.write(inspect.getsource(func).replace(func.__name__, "task"))
from tmp_func import task
if __name__ == '__main__':
func = partial(task, params)
pool = Pool(processes=8)
res = pool.map(func, iterable)
pool.close()
return res
else:
raise "Not in Jupyter Notebook"
def long_running_task(params, id):
# Heavy job here
return params, id
data_list = range(8)
for res in parallal_task(long_running_task, data_list, "a", 1, "b"):
print(res)
传送门:https://stackoverflow.com/questions/47313732/jupyter-notebook-never-finishes-processing-using-multiprocessing-python-3?r=SearchResults
来源:https://blog.csdn.net/Dby_freedom/article/details/80033762
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
PHP实现手机号码中间四位用星号(*)隐藏的自定义函数分享
Python自动扫雷实现方法
oracle 删除重复数据
Python实现排序方法常见的四种
浅谈python for循环的巧妙运用(迭代、列表生成式)
Python 解析pymysql模块操作数据库的方法
![](https://img.aspxhome.com/file/2023/9/70779_0s.jpg)
标准的、语义的、Unobtrusive的页签tab切换
![](https://img.aspxhome.com/file/UploadPic/200711/3/200711314630185s.png)
pandas删除行删除列增加行增加列的实现
python 从list中随机取值的方法
SQL Server 2000安装图解教程
![](https://img.aspxhome.com/file/UploadPic/up/2009090920263675.gif)
python中正则表达式的使用详解
![](https://img.aspxhome.com/file/2023/5/62285_0s.png)
在python中如何建立一个自己的包
![](https://img.aspxhome.com/file/2023/5/72185_0s.png)
MySQL数据库的其它安全问题
PyQt教程之自定义组件Switch Button的实现
![](https://img.aspxhome.com/file/2023/4/112184_0s.webp)
浅析Python编写函数装饰器
ASP用户登录模块的设计
详解tensorflow训练自己的数据集实现CNN图像分类
![](https://img.aspxhome.com/file/2023/3/88993_0s.png)
python 如何在 Matplotlib 中绘制垂直线
![](https://img.aspxhome.com/file/2023/0/85020_0s.png)
对python中各个response的使用说明
![](https://img.aspxhome.com/file/2023/6/115226_0s.jpg)
Python Pandas学习之series的二元运算详解
![](https://img.aspxhome.com/file/2023/9/105859_0s.png)