记录安装Jupyter以及加入Javascript

本文档详细介绍了如何安装Jupyter Notebook,包括使用Anaconda Prompt或pip,以及解决安装过程中遇到的问题。特别地,对于在Jupyter中运行JavaScript,需要安装ijavascript,并且在安装过程中可能遇到的Visual Studio和npm的依赖问题进行了讨论,提供了安装Visual Studio 2017和调整npm源的建议。最终成功安装并运行JavaScript代码。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

目录

首先

如果你有Anaconda,则进入该控制台 Anaconda Prompt 

或者用pip安装

因为我用的是jupyter lab安装,遇到错误(无视该索引,纯废话)

其次jupyter打开是默认路径

 接下来就是Javascript

安装VS

ps,设置一下镜像源,否则可能报错 

正确安装js代码

总结

心急可直接看此处


首先

如果你有Anaconda,则进入该控制台 Anaconda Prompt 

 输入下述命令

conda install jupyter notebook

或者用pip安装

(前提你已经配置好pip在系统路径中以及安装好python)

pip install jupyter
pip install jupyterlab  // 功能更完善

没有什么意外的话就可以安装成功

因为我用的是jupyter lab安装,遇到错误(无视该索引,纯废话)

然后我就遇到了一个错误:就是不能直接在cmd中启动,因为我是完成后才写该文章,貌似不能复现错误了,不好意思,如果有这个问题,就百度一下或者安装jupyter notebook。

其次jupyter打开是默认路径

为了更改默认路径,需要按照该方法进行解决:​​​​​​Jupyter更改默认工作目录的两种方法_各自前行-优快云博客_jupyter更改工作目录

我是第一种方法就成功了。注意事项就是:如果这里找不到就用系统的搜索工具,输入Jupyter Notebook

 


 接下来就是Javascript

参考网址:Jupyter Notebook 中如何运行JavaScript,安装配置(详解)_司夏的博客-优快云博客jupyter notebook 配置javascript展示 - 简书

Jupyter Notebook 中如何运行JavaScript,安装配置(详解)_司夏的博客-优快云博客

  1. 大体第一步是:npm install -g ijavascript
  2. 第二步:安装完ijavascript后执行ijsinstall (cmd中运行)
  3. 第三步:执行jupyter notebook或者ijsnotebook就会弹出notebook界面

首先要安装node.js 具体怎么安装就不赘述了

接下来安装Js,最烦的就是这个,遇到了一堆报错。

代码:npm install -g ijavascript  此处代码可能有错,下面有讲

npm ERR! code 1
npm ERR! path 你的文件夹\npm\node_modules\ijavascript\node_modules\zeromq
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node-gyp rebuild
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@7.1.2
npm ERR! gyp info using node@14.17.6 | win32 | x64
npm ERR! gyp info find Python using Python version 3.6.2 found at "你的文件夹\Python\python.exe"
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! find VS msvs_version was set from command line or npm config
npm ERR! gyp ERR! find VS - looking for Visual Studio version 2017
npm ERR! gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
npm ERR! gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer, try re-running with '--loglevel silly' for more details
npm ERR! gyp ERR! find VS looking for Visual Studio 2015
npm ERR! gyp ERR! find VS - not found
npm ERR! gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! find VS valid versions for msvs_version:
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! find VS **************************************************************
npm ERR! gyp ERR! find VS You need to install the latest version of Visual Studio
npm ERR! gyp ERR! find VS including the "Desktop development with C++" workload.
npm ERR! gyp ERR! find VS For more information consult the documentation at:
npm ERR! gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
npm ERR! gyp ERR! find VS **************************************************************
npm ERR! gyp ERR! find VS
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Could not find any Visual Studio installation to use
npm ERR! gyp ERR! stack     at VisualStudioFinder.fail (你的文件夹\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:121:47)
npm ERR! gyp ERR! stack     at 你的文件夹\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:74:16
npm ERR! gyp ERR! stack     at VisualStudioFinder.findVisualStudio2013 (你的文件夹\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:351:14)
npm ERR! gyp ERR! stack     at 你的文件夹\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:70:14
npm ERR! gyp ERR! stack     at 你的文件夹\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:372:16
npm ERR! gyp ERR! stack     at 你的文件夹\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\util.js:54:7
npm ERR! gyp ERR! stack     at 你的文件夹\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\util.js:33:16
npm ERR! gyp ERR! stack     at ChildProcess.exithandler (child_process.js:397:5)
npm ERR! gyp ERR! stack     at ChildProcess.emit (events.js:400:28)
npm ERR! gyp ERR! stack     at maybeClose (internal/child_process.js:1055:16)
npm ERR! gyp ERR! System Windows_NT 10.0.19042
npm ERR! gyp ERR! command "F:\\Js\\node.exe" "你的文件夹\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd 你的文件夹\Roaming\npm\node_modules\ijavascript\node_modules\zeromq
npm ERR! gyp ERR! node -v v14.17.6
npm ERR! gyp ERR! node-gyp -v v7.1.2
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     你的文件夹AppData\Local\npm-cache\_logs\2021-09-16T07_42_09_653Z-debug.log

关键错误就是这里


You need to install the latest version of Visual Studio

including the "Desktop development with C++" workload.

For more information consult the documentation at:

GitHub - nodejs/node-gyp: Node.js native addon build tool


网上有种解决办法就是解决node-gyp安装vuetify编译失败gyp ERR问题_桃饱の店-优快云博客,但是对我没有什么用。

安装VS

 所以我直接用过Visual Studio安装器安装了2017版本的 记得勾选C++什么的

ps,设置一下镜像源,否则可能报错 

npm安装依赖包报ERR问题汇总及处理_ruanhongbiao的专栏-优快云博客_npm安装依赖包报错

# 查看自己的安装源
npm config get registry
 
# 更换npm源为国内淘宝镜像
npm config set registry http://registry.npm.taobao.org/
 
# 或者更换为国内npm官方镜像
npm config set registry http://registry.cnpmjs.org/
 
# 还原npm源
npm config set registry https://registry.npmjs.org/

设置一下环境 npm config set msvs_version 2017 // 看你的visual studio的版本

接下来就是这个错误

C:\Windows\system32>npm install -g ijavascript
npm ERR! code 1
npm ERR! path C:\Users\zyw\AppData\Roaming\npm\node_modules\ijavascript\node_modules\zeromq
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node-gyp rebuild
npm ERR! �ڴ˽��������һ������һ����Ŀ����Ҫ���ò������ɣ������ӡ�/m�����ء�
npm ERR!   prepare-build
npm ERR!   Downloading libzmq for Windows
npm ERR! CUSTOMBUILD : error : read ECONNRESET [C:\Users\zyw\AppData\Roaming\npm\node_modules\ijavascript\node_modules\zeromq\build\libzmq.vcxproj]
npm ERR!       at TLSWrap.onStreamRead (internal/stream_base_commons.js:209:20) {
npm ERR!     errno: -4077,
npm ERR!     code: 'ECONNRESET',
npm ERR!     syscall: 'read'
npm ERR!   }
npm ERR!
npm ERR!   ** Your connection was reset. **
npm ERR!
npm ERR!   ** Are you behind a proxy or a firewall that is preventing a connection? **
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@7.1.2
npm ERR! gyp info using node@14.17.6 | win32 | x64
npm ERR! gyp info find Python using Python version 3.6.2 found at "F:\python\Python\python.exe"
npm ERR! gyp info find VS using VS2017 (15.9.28307.1684) found at:
npm ERR! gyp info find VS "F:\Visual Studio"
npm ERR! gyp info find VS run with --verbose for detailed information
npm ERR! gyp info spawn F:\python\Python\python.exe
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   'C:\\Users\\zyw\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\gyp\\gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'msvs',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   'C:\\Users\\zyw\\AppData\\Roaming\\npm\\node_modules\\ijavascript\\node_modules\\zeromq\\build\\config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   'C:\\Users\\zyw\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   'C:\\Users\\zyw\\AppData\\Local\\node-gyp\\Cache\\14.17.6\\include\\node\\common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=C:\\Users\\zyw\\AppData\\Local\\node-gyp\\Cache\\14.17.6',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=C:\\Users\\zyw\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=C:\\\\Users\\\\zyw\\\\AppData\\\\Local\\\\node-gyp\\\\Cache\\\\14.17.6\\\\<(target_arch)\\\\node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=C:\\Users\\zyw\\AppData\\Roaming\\npm\\node_modules\\ijavascript\\node_modules\\zeromq',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'C:\\Users\\zyw\\AppData\\Roaming\\npm\\node_modules\\ijavascript\\node_modules\\zeromq\\build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn F:\Visual Studio\MSBuild\15.0\Bin\MSBuild.exe
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   'build/binding.sln',
npm ERR! gyp info spawn args   '/clp:Verbosity=minimal',
npm ERR! gyp info spawn args   '/nologo',
npm ERR! gyp info spawn args   '/p:Configuration=Release;Platform=x64'
npm ERR! gyp info spawn args ]
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: `F:\Visual Studio\MSBuild\15.0\Bin\MSBuild.exe` failed with exit code: 1
npm ERR! gyp ERR! stack     at ChildProcess.onExit (C:\Users\zyw\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\build.js:194:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (events.js:400:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
npm ERR! gyp ERR! System Windows_NT 10.0.19042
npm ERR! gyp ERR! command "F:\\Js\\node.exe" "C:\\Users\\zyw\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd C:\Users\zyw\AppData\Roaming\npm\node_modules\ijavascript\node_modules\zeromq
npm ERR! gyp ERR! node -v v14.17.6
npm ERR! gyp ERR! node-gyp -v v7.1.2
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\zyw\AppData\Local\npm-cache\_logs\2021-09-16T08_08_55_832Z-debug.log

正确安装js代码

此处正确指的是在我的环境下正确,其他电脑可能按其他博主方法能安装成功。

在我查阅了无数网址后,我发现正常安装是npm install xxx -g

而安装js的代码是npm install -g ijavascript 这个-g引起了我的注意

我换了一下后发现 居然成功了!!!!!!!! 泪奔,花了我两个小时

C:\Windows\system32>npm install ijavascript -g

changed 8 packages in 19s

退出jupyter输入ctrl + c

总结

心急可直接看此处

cmd建议管理员打开

安装Anaconda,cmd输入conda install jupyter notebook

换默认地址:

  1. 打开Anaconda Prompt,运行jupyter notebook --generate-config。
  2. 根据提示路径打开jupyter_notebook_config.py文件。
  3. 找到#c.NotebookApp.notebook_dir =;去掉#,修改为c.NotebookApp.notebook_dir = ‘你的工作目录’。提示根据字典排序可以更快速的找到具体位置!
  4. 注意:分隔符‘\’要写成双斜杠‘\\’。
  5. 找到Jupyter Notebook文件,右键属性设置,在目标栏删除最后的"%USERPROFILE%"
  6. 修改完毕后,重启Juputer Notebook即可

安装node.js 和 visual studio 2017

cmd输入npm config set msvs_version 2017

cmd输入npm install ijavascript -g

cmd输入ijsinstall

cmd输入jupyter打开notebook

cmd输入ctrl + c退出notebook (好像是这个)

应该就结束了。如有其他问题,百度 or Google 

------------------------------------------------------End------------------------------------------------------------------

还要搞个封面图,人麻了

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值