Ubuntu安装miniconda并管理虚拟环境

安装miniconda # 在普通用户下操作即可,不推荐root用户操作, cd mkdir -p ~/miniconda3 wget -c https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda3/miniconda.sh bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3 rm -rf ~/miniconda3/miniconda.sh ~/miniconda3/bin/conda init bash exec bash # 更新miniconda conda update -y –all # 查看当前的虚拟环境,默认会安装一个名为base的虚拟环境 conda env list 新建当前项目的虚拟环境 # 创建名为“py38”的虚拟环境 conda create -n py38 python==3.8.0 -y # 激活虚拟环境 conda activate py38 # 更换国内pip源 pip config…

Continue Reading

Ubuntu18设置中文支持

安装相关依赖包 sudo apt install language-pack-zh-han* cd sed -i -E -e '/# Chinese char support start/,/# Chinese char support stop/d' .bashrc cat >> .bashrc <<EOF # Chinese char support start export LANG="en_US.UTF-8" export LC_CTYPE="zh_CN.UTF-8" # Chinese char support stop EOF sudo su cd sed -i -E -e '/# Chinese char support start/,/# Chinese char support stop/d'…

Continue Reading

Python3.8安装rosbag相关包

安装环境 Ubuntu 18.04 bionic Python3.8.13 安装过程 使用以下命令, pip install rosbag roslz4 ros_numpy std_msgs sensor_msgs geometry-msgs visualization-msgs actionlib-msgs nav_msgs tf2_msgs cv_bridge –extra-index-url https://rospypi.github.io/simple/ 如果超时,可以多试几次。 本人机器安装的输出日志如下, (py3813) pc@ubuntu1804_docker:~$ pip install rosbag roslz4 ros_numpy std_msgs sensor_msgs geometry-msgs visualization-msgs actionlib-msgs nav_msgs tf2_msgs cv_bridge –extra-index-url https://rospypi.github.io/simple/ Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple, https://rospypi.github.io/simple/ Collecting rosbag WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None))…

Continue Reading

sed修改文本中的双引号

示例json文件file.json内容如下, [{"name":"张国立","sex":"男","email":"[email protected]","url":"./img/1.jpg"},{"name":"张铁林","sex":"男","email":"[email protected]","url":"./img/2.jpg"},{"name":"邓婕","sex":"女","email":"[email protected]","url":"./img/3.jpg"},{"name":"张国立","sex":"男","email":"[email protected]","url":"./img/4.jpg"},{"name":"张铁林","sex":"男","email":"[email protected]","url":"./img/5.jpg"},{"name":"邓婕","sex":"女","email":"[email protected]","url":"./img/6.jpg"}] 假设要修改url字段值,用一个变量代替,shell命令如下, (py3813) pc@C01:~$ as=”0000000364.jpeg” ; sed -E -e ‘s/”name”:[ \t]{0,}”[^”]+jpe?g”/””:'”$as”‘/g’ -e ‘s/”source”:[ \t]{0,}”[^”]+jpe?g”/”source”:'”$as”‘/g’ file.json [{“name”:”张国立”,”sex”:”男”,”email”:”[email protected]”,”url”:”./img/1.jpg”},{“name”:”张铁林”,”sex”:”男”,”email”:”[email protected]”,”url”:”./img/2.jpg”},{“name”:”邓婕”,”sex”:”女”,”email”:”[email protected]”,”url”:”./img/3.jpg”},{“name”:”张国立”,”sex”:”男”,”email”:”[email protected]”,”url”:”./img/4.jpg”},{“”:0000000364.jpeg,”sex”:”男”,”email”:”[email protected]”,”source”:0000000364.jpeg},{“”:0000000364.jpeg,”source”:0000000364.jpeg,”email”:”[email protected]”,”url”:”./img/5.jpg”},{“name”:”邓婕”,”sex”:”女”,”email”:”[email protected]”,”url”:”./img/6.jpg”}]

Continue Reading

ubuntu18安装Samba

安装Samba服务 sudo apt update -y sudo apt install samba samba-common -y 新建Samba用户 sudo groupadd smb sudo useradd -s /sbin/nologin -g smb huu 设置Samba用户密码 sudo smbpasswd -a huu 配置Samba 编辑文件sudo vi /etc/samba/smb.conf,添加内容, [global] workgroup = WORKGROUP netbios name = NAS server string = Samba Server server string = NAS Samba Server TestServer security = user include…

Continue Reading

win10安装和配置Anaconda

安装Anaconda过程 下载win10对应的Anaconda安装包 下载地址 https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/ 使用gitbash里的wget下载 wget -c -P . https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2022.05-Windows-x86_64.exe 安装Anaconda 按部就班安装即可,过程有点慢。 添加环境变量 path里添加如下2个变量(假设安装路径是c:\opt\anaconda3), c:\opt\anaconda3 c:\opt\anaconda3\Scripts 配置源(此处很多帖子博客都很坑,没说到点子上) 参考一个老哥的帖子 https://www.cnblogs.com/tianlang25/p/12433025.html 进入C:\Users\你的用户,写入一下内容到.condarc并保存, ssl_verify: true show_channel_urls: true channels: – http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/win-64 – http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64 升级Anaconda 注意如果电脑开了代理,务必先关闭代理。 conda upgrade –all -y Anaconda使用 查看环境 conda env list 创建环境 conda create -n py3813 python=3.8.13 -y 激活环境 conda init 重启打开命令行终端 conda activate py3813 每个环境都是独立的,可以使用pip安装所需的软件包…

Continue Reading

Ubuntu18.04安装Anaconda

背景 经常会用到Python,免不了搭建环境,pyenv确实很好用,但是在某些平台上安装失败,比如最近在linode主机ubuntu18.04系统上安装无法自动安装pip,于是安装Anaconda就成了终极解决方案。 安装环境 ubuntu18.04 x86_64架构 Anaconda目前(2022.03.21)最新版本2021.11 安装过程 下载最新版本Anaconda Anaconda官网下载地址传送门 cd wget -c –no-check-certificate https://repo.anaconda.com/archive/Anaconda3-2021.11-Linux-x86_64.sh 下载慢的话用清华源的地址 wget -c –no-check-certificate https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2021.11-Linux-x86_64.sh chmod 775 Anaconda3-2021.11-Linux-x86_64.sh 安装Anaconda 运行下载好的sh脚本 bash Anaconda3-2021.11-Linux-x86_64.sh 接受条款协议 输入yes 默认安装在家目录 回车 接下来就是几分钟左右的安装等待 初始化 建议默认配置 安装成功 查看conda配置 初始化终端,会出现“base”字样,表示已经成功进入默认的python3.9环境 exec bash conda config –show 添加清华镜像源 conda config –add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ conda config –add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/ conda config –set…

Continue Reading

Ubuntu18.04安装pyenv

安装依赖 sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libboost-all-dev libhdf5-serial-dev libgflags-dev libgoogle-glog-dev liblmdb-dev protobuf-compiler -y sudo apt-get install bzip2 -y sudo apt-get install libbz2-dev -y sudo apt-get install libbz2-dev -y sudo apt-get install libssl-dev -y sudo apt-get install libreadline-dev -y sudo apt-get install libsqlite3-dev -y 使用自动脚本安装 curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash 添加用户环境变量 echo ‘export PATH="~/.pyenv/bin:$PATH"’…

Continue Reading

批量启动服务器上的多个服务

公司的7台服务器,每台都有十几个左右的服务,手动启动太浪费生命,于是费力气写了个脚本, 在哪个服务器运行这个脚本,就启动对应服务器上的服务。 源代码如下,   #!/bin/bash # Author : Attaboy # Date : 2018-08-13 # Date : 2018-10-18 # Date : 2018-11-06 # Date : 2018-11-09 # Date : 2018-11-26 # Date : 2018-12-03 # Date : 2018-12-06 # Date : 2019-08-07  修改成只是启动,不停止服务,去除所有参数     # Date : 2019-08-08  更新每个服务器上的服务 # Date : 2019-08-15  启动后打印启动成功的服务 swt=$1 ip_no="$(ifconfig…

Continue Reading