赞
踩
sudo chmod 777 /etc/apt/sources.list
vim /etc/apt/sources.list
先输入10000,再不断按d键删除现有的
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释 deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse # 预发布软件源,不建议启用 # deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
sudo apt-get install net-tools
历史版本下载添加链接描述
wget -P /tmp https://repo.anaconda.com/archive/Anaconda3-2020.02-Linux-x86_64.sh bash /tmp/Anaconda3-2020.02-Linux-x86_64.sh echo 'export PATH="/home/xx/anaconda3/bin:$PATH"' >> ~/.bashrc # 让每次能够显示base,有时候不用设置 source ~/.bashrc # 激活环境变量 conda update --all # 升级anaconda
- 1
- 2
- 3
- 4
- 5
创建虚拟环境conda create -n name python==3.7 -c=conda-forge使用这个默认频道
anaconda更换源
conda update -n base conda
conda install -n base conda-libmamba-solver
conda config --set experimental_solver libmamba
https://blog.csdn.net/m0_46825740/article/details/120932098
conda 更换默认源(以清华源为示例)
使用下列命令生成.condarc 配置文件,位于用户家目录下
conda config --set show_channel_urls yes
编辑.condarc 文件,清空原先内容,写入以下内容
channels:
- defaults
show_channel_urls: true
default_channels:
- http://mirrors.aliyun.com/anaconda/pkgs/main
- http://mirrors.aliyun.com/anaconda/pkgs/r
- http://mirrors.aliyun.com/anaconda/pkgs/msys2
custom_channels:
conda-forge: http://mirrors.aliyun.com/anaconda/cloud
msys2: http://mirrors.aliyun.com/anaconda/cloud
bioconda: http://mirrors.aliyun.com/anaconda/cloud
menpo: http://mirrors.aliyun.com/anaconda/cloud
pytorch: http://mirrors.aliyun.com/anaconda/cloud
simpleitk: http://mirrors.aliyun.com/anaconda/cloud
移除源
conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
如果长时间不用conda,可能会出现Client Error: Not Found for url的问题:
参考这篇文章解决链接
阿里云的conda镜像源最新的:
添加链接描述
使用conda clean -i
清空缓存。
设为默认源
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple
查看当前源
pip config list
使用下列命令可激活 anaconda 环境
source /apps/software/anaconda3/etc/profile.d/conda.sh
pycocotools在linux下的安装
https://blog.csdn.net/wlsccc/article/details/112728239
tar -xvf 解压tar.gz
tar -vczf test.tar.gz test压缩
https://www.cnblogs.com/jyaray/archive/2011/04/30/2033362.html
删除环境
conda remove -n xxx --all
conda remove package
conda remove -n learn --all // 删除learn环境及下属所有包
pip uninstall package
now_time = datetime.datetime.strptime(now_time, "%Y-%m-%d %H:%M:%S") #转datetime
time.strftime("%Y-%m-%d %H:%M:%S") #转成字符串
pd.concat(objs=[df1,df2],axis=0)
conda install nb_conda
添加和删除虚拟环境
参考链接1:知乎
参考链接2:CSDN
jupyter在windows的vscode里面,会碰到打印不了中文字符的问题,可以在前面加上,65001就是utf-8编码
!chcp 65001
!echo 中文
pip install --user tensorflow==1.9.0 -i https://pypi.doubanio.com/simple/
https://pypi.tuna.tsinghua.edu.cn/simple/
FutureWarning: Passing (type, 1) or ‘1type’ as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / ‘(1,)type’.
_np_qint8 = np.dtype([(“qint8”, np.int8, 1)])
pip uninstall numpy
pip install numpy==1.16.4
print("Downloading " + file_name + " ... ") # 开始下载
urllib.request.urlretrieve(url_base + file_name, file_path)
print("Done")
print("Converting " + file_name + " to NumPy Array ...")
with gzip.open(file_path, 'rb') as f: # 打开读取二进制数据,也可以是文本数据
data = np.frombuffer(f.read(), np.uint8, offset=16) # np.frombuffer 从流读取数据,
data = data.reshape(-1, img_size) # 一行是一个图片
print("Done")
np.uint8 0~255
>>> s = b'hello world' # b是代表bytes,还有u和r
>>> np.frombuffer(s, dtype='S1', count=5, offset=6) #偏置是6
array([b'w', b'o', b'r', b'l', b'd'], dtype='|S1')
print("Creating pickle file ...") #这里是把一个字典进行了存储
with open(save_file, 'wb') as f: #f是保存的文件名字
pickle.dump(dataset, f, -1) #-1是指定python3的序列化方式
print("Done!")
# 打开pickle文件。
with open(save_file, 'rb') as f:
dataset = pickle.load(f)
在pickle.load(f)时,可能会碰到编码错误,就需要改为pickle.load(f, encoding=‘bytes’)
https://zhuanlan.zhihu.com/p/109266820
https://zhuanlan.zhihu.com/p/59442292
需要安装个vsstudio c++那些
去官网下载wheel文件(直接下载的不对)
在安装,
建立一个setup文件
from distutils.core import setup
from Cython.Build import cythonize
setup(name='api_sign', ext_modules=cythonize(['in_main.py','main_use.py','data_load.py','subprogram.py','unique.py']))
# python setup.py build_ext --inplace
执行命令生成pyd文件:
python setup.py build_ext --inplace
生成pyd的报错处理
https://blog.csdn.net/Gavinmiaoc/article/details/84340736?utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromMachineLearnPai2%7Edefault-13.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromMachineLearnPai2%7Edefault-13.control
http://www.xoxxoo.com/index/index/article/id/772.html
Linux 系统目录结构:https://www.runoob.com/linux/linux-system-contents.html
使用windows作为ssh服务端,linux作为ssh服务端,进行连接。
ssh-keygen -t rsa
之后选择位置
一般存储在.ssh/下面
生成两个文件 [Ubuntu 20.04 LTS.lnk](Ubuntu 20.04 LTS.lnk)
id_rsa, id_rsa.pub
mkdir .ssh
touch ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
cat id_rsa.pub >> ~/.ssh/authorized_keys
把这个新的公钥添加进去
在.ssh/下新建一个config文件,没有后缀
Host my(简单常用名)
HostName ip
User myname
Port 22
IdentityFile (用的哪一个私钥)
Host my(简单常用名)
HostName ip
User myname
IdentityFile (用的哪一个私钥)
https://www.xylnk.com/2020/206.html
服务端的config一般是端口和权限配置
scp 本地文件 my:服务器路径
scp -r 本地文件夹 my:服务器路径
rsync -avP 本地文件 my:服务器路径(速度非常快,用于大文件夹)
https://www.bilibili.com/video/BV1nk4y1k742
curl -k -o Miniconda2-latest-Linux-x86_64.sh https://repo.anaconda.com/miniconda/Miniconda2-latest-Linux-x86_64.sh
https://docs.conda.io/en/latest/miniconda.html
-k是跳过ssl证书检测
-o是保存为目标文件
https://www.ruanyifeng.com/blog/2019/09/curl-reference.html这是curl的参考网站
pip freeze > requirements.txt
pip install -r requirements.txt
同平台离线
pip download -d ~/my_env_pkgs/ -r requirements.txt
pip install -r requirements.txt --no-index --find-links=file:///home/user_name/my_env_pkgs
跨平台离线
pip download --no-binary=:all: -d ~/my_env_pkgs/ -r requirements.txt
pip install -r requirements.txt --no-index --find-links=file:///home/user_name/my_env_pkgs
conda env export -f environment.yml
conda env create -f environment.yml
手动删去其中的pip的那部分,只安装里面包含的conda部分
安装(测试机器和待部署机器上都需要安装,建议在base环境安装)
conda install -c conda-forge conda-pack
导出环境
conda pack -n my_env -o out_name.tar.gz、
目标环境新建目录,一般放在.conda/envs/下面
mkdir -p my_env
解压缩进去
tar -xzf out_name.tar.gz -C my_env
目标机器激活环境,会将my_env/bin添加到path环境变量,之后方可支持conda activate
source my_env/bin/activate
部署机器上替换prefix
conda-unpack
此时如遇“Files managed by conda were found to have been deleted/overwritten …”的问题,则应该是在使用过程中误用pip卸载了用conda安装的包,此时首先需要用conda正确卸载这些包,然后再执行打包的操作
删去yml文件中的build字段
==
conda --clone还有–offline不建议使用
如果是离线主机,就直接使用联网的虚拟机,进行conda pack进去。
如果是在线主机,就使用txt和yml文件如在线下载。
参考链接
https://forskamse.blog.csdn.net/article/details/98665869
https://blog.csdn.net/shirukai/article/details/108822729
plt.rcParams.update({'figure.figsize':(9,7), 'figure.dpi':120})
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-GJOlmpI0-1636362171870)(python%E5%B8%B8%E7%94%A8%E6%93%8D%E4%BD%9C.assets/image-20210815115527645.png)]
p = d = q = range(0, 2)
pdq = list(itertools.product(p, d, q))
# 忽略警告
with warnings.catch_warnings():
warnings.filterwarnings('ignore')
error = walk_forward_validation(data, n_test, cfg)
key = str(cfg) #参数配置是元组
print(f'> Model{key} {error:.3f}')
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。