M1 Mac打开Jupyter notebook

当我成功安装了Jupyter之后,发现无法通过

复制代码
jupyter notebook

开始工作。

最初的问题是

复制代码
zsh command not found

该问题是个路径问题,通过添加PATH环境变量就行了,设置环境变量时需要注意,zshrc和bash_profile中都可以设置,二者的区别是:每打开一个新的终端,zshrc就会被source(也就是设置的PATH被刷新一次),而bash_profile每次都需要手动source。为了安全起见,我的zshrc如下

vim ~/.zshrc

复制代码
alias python='python3'
source ~/.bash_profile

:wq退出保存

vim ~/.bash_profile

复制代码
export PATH="/usr/bin:$PATH"
export PATH="/Users/peisipand/Library/Python/3.8/bin:$PATH"

这样的操作过后,就不是command找不到的问题了,而是

NotADirectoryError: Errno 20 Not a directory: 'xdg-settings'

貌似是一个很小众的问题,网上搜不到太多相关的解决方案。

这里有一个相关的回答,成功解决了我的问题。

/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/webbrowser.py

找到该文件

复制代码
def register_standard_browsers():
    global _tryorder
    _tryorder = []

    if sys.platform == 'darwin':
        register("MacOSX", None, MacOSXOSAScript('default'))
        register("chrome", None, MacOSXOSAScript('chrome'))
        register("firefox", None, MacOSXOSAScript('firefox'))
        register("safari", None, MacOSXOSAScript('safari'))
        # OS X can use below Unix support (but we prefer using the OS X
        # specific stuff)

    if sys.platform[:3] == "win":
        # First try to use the default Windows browser
        register("windows-default", WindowsDefault)

        # Detect some common Windows browsers, fallback to IE
        iexplore = os.path.join(os.environ.get("PROGRAMFILES", "C:\\Program Files"),
                                "Internet Explorer\\IEXPLORE.EXE")
        for browser in ("firefox", "firebird", "seamonkey", "mozilla",
                        "netscape", "opera", iexplore):
            if shutil.which(browser):
                register(browser, None, BackgroundBrowser(browser))

将 if sys.platform:3 == "win": 改成 elif sys.platform:3 == "win": 就可以了。

相关推荐
bossjuemfc1 小时前
不记得文件名时,Mac 上的搜索还能怎么做?
macos
2501_915909062 小时前
Windows 打开 Xcode 工程,编译调试 Xcode 项目并和 Mac 同事协作
ide·windows·vscode·macos·ios·个人开发·xcode
golang学习记3 小时前
比VS Code轻10倍,JetBrains开源全新AI IDE
ide·人工智能·jetbrains·thinkrail
请为小H留灯11 小时前
Mac 常用操作与维护技巧
macos·电脑·清理电脑·常用技巧
hantmac21 小时前
不记得文件名时,Mac 上的搜索还能怎么做?
人工智能·macos
这是谁的博客?21 小时前
AI 加速器 RTL 数字系统设计深度解析:从 MAC 阵列 Verilog 实现到时序收敛与时钟功耗的芯片落地全链路
人工智能·macos·ai·verilog·数字ic设计·ai芯片·rtl
slacker-kian21 小时前
M 系列 Mac 清除顽固的 CorpLink
macos·corplink·m系列
我要见SA姐11 天前
Chrome 内存泄漏诊断指南:从现象定位到根因排查
ide·vscode·python·自动化·编辑器
kk_net88991 天前
FSNotes:macOS 和 iOS 上的开源笔记管理器
笔记·其他·macos·ios
00后程序员张1 天前
Windows 开发 iOS App 入门,用 SwiftUI 写第一个 iOS App 装到 iPhone
ide·vscode·ios·objective-c·个人开发·swift·敏捷流程