MacOS软件安装及系统设置_新手上路_anaconda

2017-05-10  本文已影响0人  lmingzhi

MacOS软件安装及系统设置

@title: MacOS软件安装及系统设置
Created on 2017-04-18 14:19:32
@author: lmingzhi

[TOC]

参考书籍

一、软件 list

  1. Mac Shadowsockes
  1. Google Chrome
  2. macOS 强制退出软件快捷键 win(command)+Q
  3. macOS 默认右击:Ctrl + 点击
  4. 搜狗拼音输入法 Ctrl + 空格,切换输入法
  5. 坚果云(同步文件夹)
  6. 安装1password,利用 pkg 包安装,利用 license 文件
  7. dropbox 离线下载
  8. Acrobat Pro DC for mac 2015
  9. 为知笔记
  10. 有道云笔记
  11. MS office 离线 pkg
  12. 微信
  13. QQ
  14. mweb Markdown笔记 ¥99
    • 使用七牛云进行存储,图片 url 前缀http://------.glb.clouddn.com/
    • 图片文件名称原则:日期-文件名.格式
  15. rar解压缩文件,appstore 全能解压
  16. vim快捷键:Macintosh Terminal Pocket Guide PDF P66
  17. terminal 终端 ITerm2
  18. 读取移动硬盘或U盘: NTFS for Mac OS X
  19. DayOne ¥258
  20. PDFExpert ¥389(MacStore)——¥123(淘宝荔枝正版)
  21. Double Commander 32位 替代 total commander
  22. 欧路词典 ¥128 MacStore(添加牛津词典、缩略词和发音词典)
  23. Navicat (软件容易崩溃)--- 用 DataGrip代替
  24. MySQLWorkbench
  25. MySQL Server
  26. Pycharm
  27. Alfred 搜索用,剪贴板——用于替代spotlight

二、快捷键

Mac 键盘快捷键

https://support.apple.com/zh-cn/HT201236

2.1 sublime text 3

sublime 测试代码

Open a Terminal window and run:

sublime ~/Documents

or

cd
sublime Documents/

or even

# to open the entire current directory
sublime .

2.2 系统快捷键

常用快捷键

  1. macOS Spotlight搜索框 cmd + 空格
  2. MacOS 文件默认打开方式
    • 第一步:右键单击该文件,然后选择「显示简介」选项。
    • 第二步:找到「打开方式」项目,点击倒三角选择你想指定的默认应用程序。
    • 第三步:单击「全部更改」按钮即可生效。
  3. 页面放大
    • 系统偏好设置——辅助功能——缩放——配合修饰键使用滚动手势来缩放——cmd+鼠标滚轮
    • 这样在才会释放 Office 默认的 ctrl+滚轮 来缩放
    • 170426-系统缩放快捷键170426-系统缩放快捷键
  4. 删除文件 cmd + back
  5. Mac系统文件搜索(全局搜索)
    • 搜索框下面的+号
    • 点击名称框——其他——🔍输入系统文件——在菜单中□ ✔️
    • 搜索条件栏内,选择系统文件 + 包括
    • 名称 + 匹配 + 输入文件名称
    • 搜索snippets.json—— 修改nbextensions的 snippets
  6. 打开软件设置 cmd + ,

桌面并排使用2个窗口

在 Split View 中并排使用两个 Mac 应用

三、anaconda安装 MacOS系统

3.1 参考链接

ANACONDA FOR MacOS 官方安装说明

Anaconda for MacOS 下载页面

MacOS PATH 设置说明

3.2 安装步骤

  1. 安装 pkg 图形界面安装包,https://repo.continuum.io/archive/Anaconda3-4.3.1-MacOSX-x86_64.pkg(Anaconda 4.3.1 For macOS)
  2. 默认安装 anaconda 在 home user 目录


    pngpng
  3. 关键点:
    • �NOTE: Advanced users may select “customize” to not add Anaconda to the Bash path:
      pngpng
  4. 选择“Install for me only”


    pngpng

设置路径 echo $PATH

  1. 设置路径,参考macOS PATH 设置说明

    • sublime ~/.bash_profile
    • 路径位置~/anaconda/bin/
    • 显示当前环境变量:echo "$PATH"printf "%s\n" $PATH
    • 修改 vi ~/.bash_profile,添加以下命令:
      • export PATH=$PATH:~/anaconda/bin/
      • vim 使用 :wq,保存并退出
      • 保存关闭文件后,如果要立即实现,则输入:source $HOME/.bash_profile
    • 最后验证一下:echo $PATH

3.3 pip问题

解决 pip 问题 How to Modify the Shell Path in macOS Sierra and OSX using Terminal

3.4 Tsinghua 源 & aliyun 源

conda tsinghua源

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes

pip 阿里云源

mkdir ~/.pip
vim ~/.pip/pip.conf 
# 国内源
[global]
trusted-host=mirrors.aliyun.com
index-url=http://mirrors.aliyun.com/pypi/simple/

3.5 jupyter TOC

1.辨别 pip 环境路径

先看 pip 是否是 anaconda 所在目录的 pip,否则需要调整环境路径优先级别:

which pip
# /usr/local/bin/pip 该目录不满足安装要求

echo $PATH
# /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/lmingzhi/anaconda/bin/:/usr/local/mysql/bin

# 更改路径优先级别
PATH=/Users/lmingzhi/anaconda/bin/:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/mysql/bin

# 看看修改后的效果
which pip
# /Users/lmingzhi/anaconda/bin//pip # 满足pip安装要求

2.安装代码

pip install jupyter_contrib_nbextensions
jupyter contrib nbextension install --user
jupyter nbextension enable /Users/lmingzhi/anaconda/lib/python3.6/site-packages/jupyter_contrib_nbextensions/nbextensions/codefolding/main

选择 Table of Contents(2)

[I 16:30:54 InstallContribNbextensionsApp] Installing jupyter_contrib_nbextensions items to config in /Users/lmingzhi/.jupyter
Enabling: jupyter_nbextensions_configurator
- Writing config: /Users/lmingzhi/.jupyter
    - Validating...
      jupyter_nbextensions_configurator  OK
Enabling notebook nbextension nbextensions_configurator/config_menu/main...
Enabling tree nbextension nbextensions_configurator/tree_tab/main...
[I 16:30:54 InstallContribNbextensionsApp] Enabling notebook extension contrib_nbextensions_help_item/main...
[I 16:30:54 InstallContribNbextensionsApp]       - Validating: OK
[I 16:30:54 InstallContribNbextensionsApp] - Editing config: /Users/lmingzhi/.jupyter/jupyter_nbconvert_config.json
[I 16:30:54 InstallContribNbextensionsApp] --  Configuring nbconvert template path
[I 16:30:54 InstallContribNbextensionsApp] --  Configuring nbconvert preprocessors
[I 16:30:54 InstallContribNbextensionsApp] - Writing config: /Users/lmingzhi/.jupyter/jupyter_nbconvert_config.json
[I 16:30:54 InstallContribNbextensionsApp] --  Writing updated config file /Users/lmingzhi/.jupyter/jupyter_nbconvert_config.json

3.6 jupyter snippets

{
    "snippets" : [

        {
            "name" : "sqlalchemy",
            "code" : [
                "import pandas as pd",
                "from sqlalchemy import create_engine",
                "db = 'tu' # standard_db",
                "engine = create_engine(\"mysql+pymysql://root:lmingzhi08@localhost:3306/%s?charset=utf8mb4\" % db, echo=False)",
                "                       ",
                "pd.read_sql('show tables', engine)",
                "# df.to_sql('taobao', engine, if_exists='append', index=False)"
            ]
        },
        {
            "name" : "pd & np & plt",
            "code" : [
                "import pandas as pd",
                "import numpy as np",
                "import matplotlib.pyplot as plt",
                "import seaborn as sns",
                "import io",
                "",
                "from collections import defaultdict, Counter",
                "%matplotlib inline",
                "",
                "plt.rc('figure', figsize = (8.4,5))",
                "plt.rcParams['font.family'] = ['SimHei'] ",
                "plt.rcParams['axes.unicode_minus'] = False "
            ]
        },
        {
            "name" : "pymysql",
            "code" : [
                "import pymysql",
                "def sql_insert(table, data_dict):",
                "    sql = '''",
                "        INSERT INTO %s (`%s`)",
                "        VALUES (%%(%s)s );",
                "        '''   % (table, '`,  `'.join(data_dict),  ')s, %('.join(data_dict))",
                "    return sql",
                "",
                "connection = pymysql.connect(host='localhost',",
                "                             user='root',",
                "                             password='lmingzhi08',",
                "                             db='tu',",
                "                             charset='utf8',",
                "                             cursorclass=pymysql.cursors.DictCursor)",
                "",
                "item = {",
                "    'xs_name': 'name',",
                "    'xs_author':'author',",
                "    'category': 'category',",
                "    'name_id': 10",
                "}",
                "",
                "table = 'dd_name'",
                "sql = sql_insert(table, item)",
                "",
                "try:",
                "    with connection.cursor() as cursor:",
                "        cursor.execute(sql, item)",
                "        connection.commit()",
                "        print('sucess')",
                "finally:",
                "    connection.close()",
                ""
            ]
        },


        {
            "name" : "requests",
            "code" : [
                "import requests",
                "from scrapy.http import TextResponse",
                "import time",
                "def get_response(url):",
                "    r = requests.get(url, headers = {'user-agent':'Mozilla/5.0'})",
                "    print('Encodingcode:%s' % r.encoding)",
                "    response = TextResponse(r.url, body = r.text, encoding = 'utf-8')",
                "    return response, r  ",
                "    ",
                "url = ",
                "response, r = get_response(url)"
            ]
        }

    ]
}

3.7 matplotlib中文字体安装

参考 170421_matplotlib中文字体设定_macOS.md

四、MySQL安装

参考链接 mac安装mysql的两种方法(含配置)

下载链接 mysql 官网下载地址

  1. 下载 dmg 安装文件
  2. 默认安装,最后会弹出一个随机密码:iA;+qDg0ZjFu
  3. 系统偏好设置——MySQL——Start Mysql Server按钮——启动
  4. 此时我们在命令行输入mysql -uroot -p命令会提示没有commod not found,我们还需要将mysql加入系统环境变量。
  1. 现在你就可以通过mysql -uroot -p登录mysql了,会让你输入密码
  2. 登录成功后,你可以通过下面的命令修改密码
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('lmingzhi08');

这样子密码就改成了 lmingzhi08了。

命令行退出 mysql, quit 或者 ctrl+D

上一篇下一篇

猜你喜欢

热点阅读