Mac上安装jupyter、添加环境变量问题

1、直接在pycharm安装


在这里插入图片描述

pycharm的terminal打开
在这里插入图片描述

此时jupyter默认路径是当前pycharmProject的路径,这种方式Mac的终端无法直接启动。


2、mac终端安装jupyter


pip3 install jupyter

2.1 mac添加环境变量问题:遇到jupyter command not found


安装完成后, 直接在命令行里输入jupyter notebook可能会显示jupyter command not found, 这是由于 pip3 安装完 jupyter 后并没有将其加入到 mac 当前环境变量中。


2.2 环境变量加到.zshrc


Mac新系统默认终端是zsh不再是bash,默认启动的文件是.zshrc不是.bash_profile。(如果你的Mac仍然是bash则直接在.bash_profile添加环境变量)
在这里插入图片描述

会出现的问题:每次打开Terminal都需要source bash_profile,才能使用环境变量配置好的命令。比如jupyter-notebook


解决:
1、打开.zdhrc:open -e .zshrc
2、添加一行:source ~/.bash_profile,保存退出
3、终端输入:source .zshrc此时你在 .bash_profile中添加的环境变量都会一直作用成功
4、打开.bash_profile: open -e .bash_profile
5、添加环境变量:jupyter-notebook的安装路径(一般也是python的安装路径)export PATH=/Library/Frameworks/Python.framework/Versions/3.9/bin/:$PATH
在这里插入图片描述

6、source ~/.bash_profile
7、此时终端直接输入:jupyter-notebook(默认路径就是你的终端默认路径/Users/mac/
当然你也可以直接在.zdhrc中添加环境变量。


MAC一些操作:


1、环境变量


1、 查看所有环境变量echo $PATH
在这里插入图片描述
2、which:得到在环境变量$PATH目录下的文件 的绝对路径
locate a program file in the user’s path

  • jupyter如果已经在环境变量路径下:which jupyter:则会显示:/Library/Frameworks/Python.framework/Versions/3.9/bin//jupyter
    在这里插入图片描述

2、路径


1、查看文件完整路径:把该文件拖入终端即可

2、前往某个文件夹:

  • finder–前往–输入路径

3、查案当前工作目录完整路径:pwd
pwd的原意是:print work directiory


3、打开文件[夹]open


  • open 文件路径:如open downloads/qian2.py
  • 文本编辑器模式打开:open -e

2、查看命令详细用法

man 命令名

例如 man open :

  • 用文本编辑器打开:-e Causes the file to be opened with /Applications/TextEdit
    在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_42810939/article/details/123973250
今日推荐