linux工作中软件运行安装常见问题

本文主要内容是使用linux软件安装 以及运行时常出现的一些问题,主要如下:

  1. sudo apt-get update(Unable to fetch some archives问题)

  2. soure . 的区别

  3. export LD_LIBRARY_PATH使用(.so文件not found) .bashrc

  4. ldconfig

  5. string | bash使用(将字符串转为可以执行的bash命令)

  6. pip install *.whl(主要是在现在pip install 时候http time out故而下载pylib.whl手动安装) anaconda作为默认python解释器python版本选择

1. sudo apt-get update(Unable to fetch some archives问题)


有时候在sudo apt-get install lib 的时候往往忘记了执行
sudo apt-get update 会出现下面的错误
这里写图片描述

apt-get is a command-line tool which Ubuntu uses to install, remove,
and manage software packages
update
is an option for the apt-get
program to use which updates the package lists from a server on the
internet. The package lists provide the apt-get utility with important
information about the software packages that you can install using
apt-get. apt-get uses these lists to determine which software to
install when given a command to install.

因此我们最好执行一下 sudo apt-get update,当然很多时候不执行也没什么
与之对应的是 sudo apt-get upgrade(最好不要执行,会更新系统的所有文件)

soure . 的区别


source . 命令 (通常用于重新执行刚修改的初始化文件)
source ~/.bashrc (环境变量)

source .区别

When you source the script you are typing the commands in your currentshell.
Any changes to the environment will take effect and stay in your current shell. Use source if you want the script to change theenvironment in your currently running shell
(source的执行在当前的shell下面,所有环境变量对当前shell生效)

. 启动一个新的shell环境变量对当前的shell不生效
故而一般更新环境变量的相关的时候使用source如source ~/.bashrc (环境变量)

export LD_LIBRARY_PATH使用(.so文件not found) .bashrc


比如我在使用caffe的时候为local user安装了caffe但是切换到sudo -i 的时候使用报错

ImportError: libcaffe-nv.so.0.15: cannot open shared object file: No such file or directory
>>> 
locate libcaffe-nv.so.0.15
/data1/aladdin/caffe_test/caffe-caffe-0.15/.build_release/lib/libcaffe-nv.so.0.15
/data1/aladdin/caffe_test/caffe-caffe-0.15/.build_release/lib/libcaffe-nv.so.0.15.14
export LD_LIBRARY_PATH=/data1/aladdin/caffe_test/caffe-caffe-0.15/.build_release/lib/:$LD_LIBRAYA_PATH

这里写图片描述

这里写图片描述

Library at "libcaffe.so.1.0.0 does not have expected suffix "-nv"

ImportError: libcaffe-nv.so.0.15: cannot open shared object file: No such file or directory
locate libcaffe-nv.so.0.15
/data1/aladdin/caffe_test/caffe-caffe-0.15/.build_release/lib/libcaffe-nv.so.0.15
/data1/aladdin/caffe_test/caffe-caffe-0.15/.build_release/lib/libcaffe-nv.so.0.15.14

export LD_LIBRARY_PATH=/data1/aladdin/caffe_test/caffe-caffe-0.15/.build_release/lib/:$LD_LIBRAYA_PATH

LD_LIBRARY_PATH: native code libraries (on Linux, in addition to the value of this variable, the lookup path typically contains /usr/local/lib, /usr/lib, /lib and a few others). The name  LD comes from dynamic loader, the system component that loads libraries into dynamically linked executables.
PERL5LIB: Perl libraries (e.g. /usr/local/lib/site-perl:/usr/lib/perl:/usr/share/perl).
PYTHONPATH: Python libraries (e.g. /usr/local/lib/python:/usr/lib/python).
PATH is for specifying directories of executable programs. LD_LIBRARY_PATH is used to specify directories of libraries.
To define this variable, simply use (on the shell prompt):

export LD_LIBRARY_PATH="/path/to/sdk/lib"

永久的使用
sudo vi ~/.bashrc
the end of the file, add
export LD_LIBRARY_PATH="/path/to/sdk/lib"
then  source ~/.bashrc

LD_LIBRARY_PATH主要是可以指定.so等文件的路径问题
有时候我们可能还要配合 ln -s 一起使用,示例如下:
这里写图片描述

截图来源与我自己的技术[笔记](https://github.com/Jayhello/MyNote “已经上传到github”)主要是针对自己个人的所以看起来有点乱

ldconfig


ldconfig (是一个动态链接库管理命令)
1、往/lib和/usr/lib里面加东西,是不用修改/etc/ld.so.conf的,
但是完了之后要调一下ldconfig,不然这个library会找不到
2、ldconfig 命令的用途,主要是在默认搜寻目录(/lib和/usr/lib)以及动态
库配置文件/etc/ld.so.conf内所列的目录下,搜索出可共享的动态 链接库(格式如前介绍,lib*.so*)
这里写图片描述

string | bash使用


主要是将字符串转为可以执行的bash命令首先看个简单示例:
这里写图片描述

下面高级点的示例将文件批量重命名为 0001.jpg~0023.jpg

find -name '*.jpg' \  # find jpgs
| awk 'BEGIN{ a=0 }{ printf "mv \"%s\" %04d.jpg\n", $0, a++ }'  # build mv command
| bash # run that command

批量重命名可以见我的另外一篇bolg

pip install *.whl(主要是在现在pip install 时候http time out故而下载pylib.whl手动安装)


use anaconda’s python instead of standard /usr/lib/python
export PATH=” HOME/anaconda/bin: PATH”
这里写图片描述
永久的使用

sudo vi ~/.bashrc
the end of the file, add
export PATH="$HOME/anaconda/bin:$PATH"
then  source ~/.bashrc

pip install 的时候有时候老是出现HTTP time out这时候,可以手动下载对应的 *.whl文件然后安装
这里写图片描述

转载注明出处哈(CTLR+L即可选择url,再CTRL+C复制即可)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值