前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >linux工作中软件运行安装常见问题

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

作者头像
bear_fish
发布2018-09-14 10:07:13
9690
发布2018-09-14 10:07:13
举报

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://cloud.tencent.com/developer/article/1338390

本文主要内容是使用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 updateundefined 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.undefined 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 的时候使用报错

代码语言:javascript
复制
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
代码语言:javascript
复制
export LD_LIBRARY_PATH=/data1/aladdin/caffe_test/caffe-caffe-0.15/.build_release/lib/:$LD_LIBRAYA_PATH
代码语言:javascript
复制
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
代码语言:javascript
复制
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 一起使用,示例如下:

截图来源与我自己的技术笔记主要是针对自己个人的所以看起来有点乱

ldconfig


ldconfig (是一个动态链接库管理命令)

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

string | bash使用


主要是将字符串转为可以执行的bash命令首先看个简单示例:

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

代码语言:javascript
复制
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:HOME/anaconda/bin:PATH”

永久的使用

代码语言:javascript
复制
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复制即可)

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2017年08月31日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 1. sudo apt-get update(Unable to fetch some archives问题)
  • soure . 的区别
  • export LD_LIBRARY_PATH使用(.so文件not found) .bashrc
  • ldconfig
  • string | bash使用
  • pip install *.whl(主要是在现在pip install 时候http time out故而下载pylib.whl手动安装)
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档