如果出现提示,是否有快速安装软件包的方法?

如果出现提示,是否有快速安装软件包的方法?

如果我想安装一个包,

wlhunag: ~ $ pip install django
The program 'pip' is currently not installed. You can install it by typing:
sudo apt-get install python-pip
wlhunag: ~ $

我想知道是否有一种快速的方法来安装所需的软件包,而无需手动键入该行

sudo apt-get install python-pip

答案1

它来自 command-not-found,它是从 shell 脚本运行的...所以你可以修改 shell 函数来给出“你想安装它吗”提示,或者将它保留在一个变量中(这样你就可以了) d 然后只需键入$doINST或其他内容)。或者使用history -s将它们附加到历史记录中,然后您只需按向上键即可。

答案2

剪切和粘贴是最快的安装包。如果您在 gnome 终端中,您可以三次单击该sudo apt-get ...行,然后按Ctrl+ Shift+ C(复制),然后按Ctrl+ Shift+ V(粘贴),然后按Return

但是,就您的情况而言,我建议您这样做:

wget https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py

所以你有最新版本,它可能不在您使用 . 安装时获得的存储库中apt-get

如果您有 Python 2.7.9 或任何 3.4 系列,pip则包含在分配并且您不需要安装它。

答案3

查看aptsh。刚刚偶然发现的。示例会话(在 shell 中点击选项卡会执行智能选项卡补全):

root@orwell:/home/faheem# aptsh
Generating and mapping caches...
Reading commands history...
aptsh> 
add              depends          dump-cfg         madison          queue*           show             unmet            
autoclean        dist-upgrade     dumpavail        news             quit             showpkg          update           
build-dep        dotty            help*            orphans*         rdepends         showsrc          upgrade          
changelog        dpkg*            install          pkgnames         remove           source           whatis           
check            dselect-upgrade  listfiles        policy           rls              stats            whichpkg         
clean            dump             ls               purge            search           toupgrade        
aptsh> install octave
Display all 113 possibilities? (y or n)
octave                        octave-fpl                    octave-miscellaneous          octave-plot                   octave-zenity
octave-ad                     octave-ftp                    octave-missing-functions      octave-plplot                 octave2.0-emacsen
octave-ann                    octave-ga                     octave-mpi                    octave-psychtoolbox-3         octave2.0-htmldoc
octave-audio                  octave-gdf                    octave-msh                    octave-quaternion             octave2.0-info
octave-benchmark              octave-general                octave-multicore              octave-secs1d                 octave3.0
octave-bim                    octave-geometry               octave-nan                    octave-secs2d                 octave3.0-info
octave-bioinfo                octave-gmt                    octave-nlopt                  octave-signal                 octave3.1
octave-biosig                 octave-gsl                    octave-nlwing2                octave-simp                   octave3.1-doc
octave-combinatorics          octave-headers                octave-nnet                   octave-sockets                octave3.1-emacsen
octave-common                 octave-htmldoc                octave-nurbs                  octave-sp                     octave3.1-headers
octave-communications         octave-ident                  octave-ocs                    octave-specfun                octave3.1-htmldoc
octave-communications-common  octave-image                  octave-octcdf                 octave-splines                octave3.1-info
octave-control                octave-info                   octave-octgpr                 octave-statistics             octave3.2
octave-data-smoothing         octave-informationtheory      octave-odepkg                 octave-strings                octave3.2-common
octave-dataframe              octave-integration            octave-openmpi-ext            octave-struct                 octave3.2-dbg
octave-dbg                    octave-io                     octave-optim                  octave-sundials               octave3.2-doc
octave-dicom                  octave-irsa                   octave-optiminterp            octave-symband                octave3.2-emacsen
octave-doc                    octave-java                   octave-outliers               octave-symbolic               octave3.2-headers
octave-econometrics           octave-lhapdf                 octave-parallel               octave-time                   octave3.2-htmldoc
octave-emacsen                octave-linear-algebra         octave-pdb                    octave-tsa                    octave3.2-info
octave-epstk                  octave-ltfat                  octave-pfstools               octave-vlfeat                 octavede
octave-financial              octave-ltfat-common           octave-physicalconstants      octave-vrml                   
octave-fixed                  octave-mapping                octave-pkg-dev                octave-xraylib                
aptsh> install octave-
octave-ad                     octave-epstk                  octave-irsa                   octave-octgpr                 octave-sockets
octave-ann                    octave-financial              octave-java                   octave-odepkg                 octave-sp
octave-audio                  octave-fixed                  octave-lhapdf                 octave-openmpi-ext            octave-specfun
octave-benchmark              octave-fpl                    octave-linear-algebra         octave-optim                  octave-splines
octave-bim                    octave-ftp                    octave-ltfat                  octave-optiminterp            octave-statistics
octave-bioinfo                octave-ga                     octave-ltfat-common           octave-outliers               octave-strings
octave-biosig                 octave-gdf                    octave-mapping                octave-parallel               octave-struct
octave-combinatorics          octave-general                octave-miscellaneous          octave-pdb                    octave-sundials
octave-common                 octave-geometry               octave-missing-functions      octave-pfstools               octave-symband
octave-communications         octave-gmt                    octave-mpi                    octave-physicalconstants      octave-symbolic
octave-communications-common  octave-gsl                    octave-msh                    octave-pkg-dev                octave-time
octave-control                octave-headers                octave-multicore              octave-plot                   octave-tsa
octave-data-smoothing         octave-htmldoc                octave-nan                    octave-plplot                 octave-vlfeat
octave-dataframe              octave-ident                  octave-nlopt                  octave-psychtoolbox-3         octave-vrml
octave-dbg                    octave-image                  octave-nlwing2                octave-quaternion             octave-xraylib
octave-dicom                  octave-info                   octave-nnet                   octave-secs1d                 octave-zenity
octave-doc                    octave-informationtheory      octave-nurbs                  octave-secs2d                 
octave-econometrics           octave-integration            octave-ocs                    octave-signal                 
octave-emacsen                octave-io                     octave-octcdf                 octave-simp                   
aptsh> install octave-io 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  gnuplot-x11 libatlas3-base libcamd2.2.0 libccolamd2.7.1 libcholmod1.7.1 libcxsparse2.2.3 libgl2ps0 libglpk0 libjexcelapi-java liboctave1 libqhull5
  libqrupdate1 octave octave-common octave-java
Suggested packages:
  gnuplot-doc libiodbc2-dev libmysqlclient-dev octave-info octave-doc octave-htmldoc
The following packages will be REMOVED:
  gnuplot-nox
The following NEW packages will be installed:
  gnuplot-x11 libatlas3-base libcamd2.2.0 libccolamd2.7.1 libcholmod1.7.1 libcxsparse2.2.3 libgl2ps0 libglpk0 libjexcelapi-java liboctave1 libqhull5
  libqrupdate1 octave octave-common octave-io octave-java
0 upgraded, 16 newly installed, 1 to remove and 1 not upgraded.
Need to get 9,850 kB/22.1 MB of archives.
After this operation, 64.6 MB of additional disk space will be used.
Do you want to continue [Y/n]? 

答案4

如果你使用 bash,你可以添加以下内容:

alias api='sudo apt-get install'

或者

alias api='sudo aptitude install'

您只需输入 api“包名称”。或者,如果您只寻找 python,您可以安装此处找到的 anaconda:https://store.continuum.io/cshop/anaconda/

然后你可以使用 conda update 来更新 anaconda 中找到的所有软件包。

相关内容