win10 jupyter notebook使用python虚拟环境

windows10环境 python3.7 使用pycharm的虚拟环境

1、新建pycharm的python虚拟环境

点击pycharm->file->settings->Project Interpreter->点击设置->add

弹出如下界面

新建 Virtualenv Environment 虚拟环境,点击OK完成,这样python虚拟环境就建好啦。

2、安装jupyter notebook

使用本地pip安装jupyter ,执行如下命令:

pip3 install jupyter

打开win10 cmd窗口,快捷方式windows+R ,输入cmd,按下回车键,输入 jupyter notebook,过一会儿弹出jupyter网页,说明已经安装成功。

3、配置jupyter,使用python虚拟环境

输入命令 jupyter kernelspec list 找到jupyter内核配置地址如下

 c:\users\*\*\*\programs\python\python37\share\jupyter\kernels\python3

win10使用cd  c:\users\*\*\*\programs\python\python37\share\jupyter\kernels\python3

打开kernel.json文件进行如下配置:

{
 "argv": [
  "D:\\*\\*\\*\\venv\\Scripts\\python",
  "-m",
  "ipykernel_launcher",
  "-f",
  "{connection_file}"
 ],
 "display_name": "Python 3 (ipykernel)",
 "language": "python",
 "metadata": {
  "debugger": true
 }
}

将第3行改为自己python虚拟环境所在的路径,即:D:\\*\\*\\*\\venv\\Scripts\\python

关闭jupyter的网站,重新打开,此时所用内核已经为python虚拟环境啦

验证代码

# jupyter notebook执行如下代码
import os, sys
print(sys.executable) # works this time
print(sys.version)
print(sys.version_info)

参考文章

jupyter notebook使用python虚拟环境_mb5fdb133c76a49的技术博客_51CTO博客

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
引用\[1\]:我使用anaconda安装的python3.8,后来自己建立一个虚拟环境用来跑maskrcnn,虚拟环境下的python版本也是3.7.11,然后运行使用jupyter运行maskrcnn-benchmark/demo/Mask_R-CNN_demo.ipynb时,一直加载不出来我想要的环境里面的包。\[1\]引用\[2\]:打开kernel.json文件进行如下配置: { "argv": \[ "D:\\*\\*\\*\\venv\\Scripts\\python", "-m", "ipykernel_launcher", "-f", "{connection_file}" \], "display_name": "Python 3 (ipykernel)", "language": "python", "metadata": { "debugger": true } }\[2\]引用\[3\]:运行结果包含一个位置,如下图所示: 接下来,去到虚拟环境python的这个文件夹下,并打开kernel.json这个文件,文件内容如下: 可以看到我运行程序是默认的是3.8版本的那个python,接下来手动修改为3.7.11那个版本的即可,如下:\[3\] 问题:用jupyter打开虚拟python环境时遇到了问题,如何解决? 回答: 如果你想在jupyter使用虚拟python环境,你需要进行一些配置。首先,打开kernel.json文件进行如下配置:{ "argv": \[ "D:\\*\\*\\*\\venv\\Scripts\\python", "-m", "ipykernel_launcher", "-f", "{connection_file}" \], "display_name": "Python 3 (ipykernel)", "language": "python", "metadata": { "debugger": true } }\[2\]。然后,找到虚拟环境python文件夹下的kernel.json文件,并将其中的默认版本修改为你想要使用的版本,比如3.7.11\[3\]。这样就可以在jupyter中打开虚拟python环境了。 #### 引用[.reference_title] - *1* *3* [实现更换Jupyter Notebook内核Python版本](https://blog.csdn.net/qq_41207620/article/details/122004366)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [win10 jupyter notebook使用python虚拟环境](https://blog.csdn.net/qq_24993119/article/details/125357993)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值