快捷键
命令行 | 作用 |
---|---|
control+A/E | 移到命令的行首、行尾 |
control+U | 清除命令 |
1、网络问题
(1)ssl_error_syscall in connection to raw.githubusercontent.com:443
禁用IPV6:networksetup -setv6off Wi-Fi
ssl_error_syscall in connection to raw.githubusercontent.com:443
(2)pip安装python库显示ssh问题
解决办法
建立文件~/.pip/pip.config
并且更改文件权限:sudo chmod 755 pip.conf
,在该文件中进行如下配置:
[global]
index-url = http://pypi.douban.com/simple #豆瓣源,可以换成其他的源
extra-index-url = https://pypi.tuna.tsinghua.edu.cn/simple
trusted-host =
pypi.douban.com #添加豆瓣源为可信主机,要不然可能报错
pypi.tuna.tsinghua #清华
timeout = 120
(3) Unable to add a source with url https://github.com/CocoaPods/Specs.git
named cocoapods
.
可以先在~/.cocoapods/repos/
目录通过git clone https://github.com/CocoaPods/Specs.git master
下载到本地
2、shell相关
(1)为.sh脚本文件创建别名
首先给脚本文件添加执行权限:chmod +x <file>
,然后在~/.zshrc
中添加:alias <别名>="xxx/<file>"
。
(2)WARNING: The scripts pip, pip3 and pip3.8 are installed in ‘/Users/[name]>/Library/Python/3.8/bin’ which is not on PATH.
› echo 'export PATH=/Users/[name]/Library/Python/3.8/bin:$PATH' >>~/.zshrc
› python3 -m pip install --upgrade --force-reinstall pip
更新pip
(3)Insecure world writable dir /opt/homebrew/bin in PATH, mode 040777
利用chmod go-w /opt/homebrew/bin
解决,表示移除group和others对文件的write权限。
3、 Homebrew相关问题
(1)brew install node
时提示tar
的问题,可以brew update
。
RequestError: connect ETIMEDOUT/socket hang up
往往是代理的问题,可以执行npm config set proxy null
,不行的话直接npm config delete proxy
。
(2) pip No module named typing
curl -O https://bootstrap.pypa.io/pip/2.7/get-pip.py
python get-pip.py
python -m pip install --upgrade "pip < 21.0"
之后使用sudo easy_install requests
或pip2.7 install prettytable
等,可以为python2.7
安装库。
(3) Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
pip install -U setuptools
(4)ModuleNotFoundError: No module named xxx
使用pip install xxx
时安装了python库,但是运行.py
文件时发现找不到库,这跟python运行时寻找库的文件有关。
先python3
在终端运行python,import sys
之后输入sys.path
找到site-packages
这个文件夹对应的库目录,然后在这个目录下进行安装就可以了。
pip3 install xxx --target=<path>
4、M1问题
(1)pod install遇到 [!] Oh no, an error occurred.
先执行sudo arch -x86_64 gem install ffi
,以后在pod install
之前加上arch -x86_64
,嫌麻烦可配置alias。
(2)python3 import module not found
lz4
一直提示里面的ImportError: dlopen(/opt/homebrew/lib/python3.9/site-packages/lz4/_version.cpython-39-darwin.so, 2): no suitable image found. Did find:
几经周折,发现是M1芯片python的不同用法。
首先可以通过python3
-> import importlib.machinery
-> print(importlib.machinery.all_suffixes())
看一下电脑支持解析的打包的python
库。=> ['.py', '.pyc', '.cpython-39-darwin.so', '.abi3.so', '.so']
.
然后通过file $(which python)
:
/usr/bin/python: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64e:Mach-O 64-bit executable arm64e]
/usr/bin/python (for architecture x86_64): Mach-O 64-bit executable x86_64
/usr/bin/python (for architecture arm64e): Mach-O 64-bit executable arm64e
这个arm64e
就是问题所在,最后可以通过/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/chinitaberrio/tensorflow_macos/master/scripts/download_and_install.sh)"
创建一个新的env
环境安装python3.8
。安装完毕之后激活一下该env
。