在Ubuntu 12.04 VM上通过2.7.3创建/安装Python 2.7.6,无法找到pip安装的软件包

时间:2016-12-16 00:29:48

标签: python python-2.7

我的Ubuntu 12.04.5 LTS VM在/ usr / bin中已经有Python 2.7.3了:

$ ls -ld /usr/bin/py*
-rwxr-xr-x 1 root root    4124 Jun 18  2013 /usr/bin/pyclean
-rwxr-xr-x 1 root root   11933 Jun 18  2013 /usr/bin/pycompile
lrwxrwxrwx 1 root root       8 Jun 18  2013 /usr/bin/pydoc -> pydoc2.7
-rwxr-xr-x 1 root root      79 Oct 26 14:35 /usr/bin/pydoc2.7
lrwxrwxrwx 1 root root      12 Jun 18  2013 /usr/bin/pygettext -> pygettext2.7
-rwxr-xr-x 1 root root   22103 Oct 26 14:35 /usr/bin/pygettext2.7
-rwxr-xr-x 1 root root     217 Mar  9  2012 /usr/bin/pyhtmlizer
lrwxrwxrwx 1 root root       9 Jun 18  2013 /usr/bin/python -> python2.7
lrwxrwxrwx 1 root root       9 Jun 18  2013 /usr/bin/python2 -> python2.7
-rwxr-xr-x 1 root root 2997528 Oct 26 14:36 /usr/bin/python2.7
-rwxr-xr-x 1 root root    1652 Oct 26 14:35 /usr/bin/python2.7-config
lrwxrwxrwx 1 root root      29 Jun 18  2013 /usr/bin/pyversions -> ../share/python/pyversions.py

我昨天做了一个wget / configure / make / install of Python 2.7.6,并且pip安装了一些模块,比如braceexpand和pytz(使用/ usr / bin / pip)。

wget  https://www.python.org/ftp/python/2.7.6/Python-2.7.6.tgz  
tar xvfz Python-2.7.6.tgz
cd Python-2.7.6
./configure
make
sudo make install

# add more
sudo apt-get install python2.7-dev
wget https://pypi.python.org/packages/c7/14/c4ea891fd8943623dcb325ab1194a1473351b02b82c3c58c8a4179027fdb/python-cdb-0.35.tar.gz
sudo pip install python-cdb-0.35.tar.gz
sudo pip install pytz
sudo pip install braceexpand
sudo pip install html

所有模块都安装到/usr/local/lib/python2.7/dist-packages(并且是唯一的东西)

$ ls -l /usr/local/lib/python2.7/dist-packages/
total 200
drwxr-sr-x 2 root staff  4096 Dec 14 22:12 braceexpand-0.1.2.egg-info
-rwxr-xr-x 1 root staff  6218 Dec 14 22:12 braceexpand.py
-rwxr-xr-x 1 root staff  6842 Dec 14 22:43 braceexpand.pyc
-rwxr-xr-x 1 root staff  6842 Dec 14 22:43 braceexpand.pyo
-rwxr-xr-x 1 root staff 87794 Dec 14 22:14 cdbmodule.so
drwxr-sr-x 2 root staff  4096 Dec 14 22:13 html-1.16.egg-info
-rwxr-xr-x 1 root staff 19209 Dec 14 22:13 html.py
-rwxr-xr-x 1 root staff 22326 Dec 14 22:43 html.pyc
-rwxr-xr-x 1 root staff 22326 Dec 14 22:43 html.pyo
drwxr-sr-x 2 root staff  4096 Dec 14 22:14 python_cdb-0.35.egg-info
drwxr-sr-x 3 root staff  4096 Dec 14 22:34 pytz
drwxr-sr-x 2 root staff  4096 Dec 14 22:16 pytz-2016.10.egg-info

不是/usr/lib/python2.7/dist-packages(已经有很多其他模块)

$ ls -l /usr/lib/python2.7/dist-packages/
total 1968
drwxr-xr-x  3 root root   4096 Nov  6  2014 apt
-rw-r--r--  1 root root  60240 Jan 24  2014 apt_inst.so
-rw-r--r--  1 root root 346320 Jan 24  2014 apt_pkg.so
drwxr-xr-x  2 root root   4096 Nov  6  2014 aptsources
drwxr-xr-x 29 root root   4096 Nov  6  2014 boto
lrwxrwxrwx  1 root root     43 Jun 27  2013 boto-2.2.2.egg-info -> ../../../share/pyshared/boto-2.2.2.egg-info
drwxr-xr-x  2 root root   4096 Nov  6  2014 chardet
lrwxrwxrwx  1 root root     46 Dec 30  2011 chardet-2.0.1.egg-info -> ../../../share/pyshared/chardet-2.0.1.egg-info
drwxr-xr-x  7 root root   4096 Nov  6  2014 Cheetah
drwxr-xr-x  2 root root   4096 Nov  6  2014 Cheetah-2.4.4.egg-info
drwxr-xr-x  3 root root   4096 Jul 20 15:27 cloudinit
lrwxrwxrwx  1 root root     49 Oct 21  2014 cloud_init-0.6.3.egg-info -> ../../../share/pyshared/cloud_init-0.6.3.egg-info
drwxr-xr-x  2 root root   4096 Nov  6  2014 CommandNotFound
lrwxrwxrwx  1 root root     57 Apr 17  2012 command_not_found-0.2.44.egg-info -> ../../../share/pyshared/command_not_found-0.2.44.egg-info
drwxr-xr-x  2 root root   4096 Nov  6  2014 computerjanitor
drwxr-xr-x  2 root root   4096 Nov  6  2014 configobj-4.7.2.egg-info
lrwxrwxrwx  1 root root     36 Dec 30  2011 configobj.py -> ../../../share/pyshared/configobj.py
-rw-r--r--  1 root root  65941 Nov  6  2014 configobj.pyc
drwxr-xr-x  9 root root   4096 Nov  6  2014 Crypto
drwxr-xr-x  2 root root   4096 Nov  6  2014 curl
drwxr-xr-x  3 root root   4096 Nov  6  2014 dbus
-rw-r--r--  1 root root 163024 Jan 27  2012 _dbus_bindings.so
-rw-r--r--  1 root root  10952 Jan 27  2012 _dbus_glib_bindings.so
lrwxrwxrwx  1 root root     33 Jan 25  2012 deb822.py -> ../../../share/pyshared/deb822.py
-rw-r--r--  1 root root    317 Nov  6  2014 deb822.pyc
lrwxrwxrwx  1 root root     34 Mar 15  2012 debconf.py -> ../../../share/pyshared/debconf.py
-rw-r--r--  1 root root   5888 Nov  6  2014 debconf.pyc
drwxr-xr-x  2 root root   4096 Nov  6  2014 debian
drwxr-xr-x  2 root root   4096 Nov  6  2014 debian_bundle
drwxr-xr-x  2 root root   4096 Dec 14 20:58 distribute-0.6.24dev_r0.egg-info
drwxr-xr-x  2 root root   4096 Nov  6  2014 DistUpgrade
lrwxrwxrwx  1 root root     39 Oct 22  2011 easy_install.py -> ../../../share/pyshared/easy_install.py
-rw-r--r--  1 root root    315 Dec 14 20:59 easy_install.pyc
drwxr-xr-x  4 root root   4096 Nov  6  2014 euca2ools
lrwxrwxrwx  1 root root     48 Jun  4  2012 euca2ools-2.0.0.egg-info -> ../../../share/pyshared/euca2ools-2.0.0.egg-info
drwxr-xr-x  6 root root   4096 Nov  6  2014 gi
lrwxrwxrwx  1 root root     53 Dec 30  2011 GnuPGInterface-0.3.2.egg-info -> ../../../share/pyshared/GnuPGInterface-0.3.2.egg-info
lrwxrwxrwx  1 root root     41 Dec 30  2011 GnuPGInterface.py -> ../../../share/pyshared/GnuPGInterface.py
-rw-r--r--  1 root root  22520 Nov  6  2014 GnuPGInterface.pyc
drwxr-xr-x  2 root root   4096 Nov  6  2014 httplib2
lrwxrwxrwx  1 root root     47 Sep  6  2013 httplib2-0.7.2.egg-info -> ../../../share/pyshared/httplib2-0.7.2.egg-info
drwxr-xr-x  2 root root   4096 Nov  6  2014 HweSupportStatus
lrwxrwxrwx  1 root root     40 Sep 13  2013 ipachangeconf.py -> ../../../share/pyshared/ipachangeconf.py
-rw-r--r--  1 root root  16716 Nov  7  2014 ipachangeconf.pyc
drwxr-xr-x  5 root root   4096 Nov  6  2014 keyring
drwxr-xr-x  2 root root   4096 Nov  6  2014 keyring-0.9.2.egg-info
drwxr-xr-x  2 root root   4096 Nov  6  2014 LanguageSelector
drwxr-xr-x  2 root root   4096 Nov  6  2014 language_selector-0.1.egg-info
lrwxrwxrwx  1 root root     48 Sep 13  2013 language_support_pkgs.py -> ../../../share/pyshared/language_support_pkgs.py
-rw-r--r--  1 root root   9733 Nov  6  2014 language_support_pkgs.pyc
drwxr-xr-x  4 root root   4096 Nov  6  2014 launchpadlib
drwxr-xr-x  2 root root   4096 Nov  6  2014 launchpadlib-1.9.12.egg-info
drwxr-xr-x  4 root root   4096 Nov  6  2014 lazr
drwxr-xr-x  2 root root   4096 Nov  6  2014 lazr.restfulclient-0.12.0.egg-info
lrwxrwxrwx  1 root root     59 Jun 14  2013 lazr.restfulclient-0.12.0-nspkg.pth -> ../../../share/pyshared/lazr.restfulclient-0.12.0-nspkg.pth
drwxr-xr-x  2 root root   4096 Nov  6  2014 lazr.uri-1.0.3.egg-info
lrwxrwxrwx  1 root root     48 Jan 25  2012 lazr.uri-1.0.3-nspkg.pth -> ../../../share/pyshared/lazr.uri-1.0.3-nspkg.pth
lrwxrwxrwx  1 root root     38 Jun 13  2013 lsb_release.py -> ../../../share/pyshared/lsb_release.py
-rw-r--r--  1 root root   7587 Nov  6  2014 lsb_release.pyc
drwxr-xr-x  4 root root   4096 Nov  6  2014 M2Crypto
drwxr-xr-x  2 root root   4096 Nov  6  2014 M2Crypto-0.21.1.egg-info
drwxr-xr-x  2 root root   4096 Nov  6  2014 oauth
drwxr-xr-x  2 root root   4096 Nov  6  2014 oauth-1.0.1.egg-info
drwxr-xr-x  3 root root   4096 Nov  6  2014 OpenSSL
lrwxrwxrwx  1 root root     42 Mar  8  2012 PAM-0.4.2.egg-info -> ../../../share/pyshared/PAM-0.4.2.egg-info
-rw-r--r--  1 root root  19640 Mar  8  2012 PAMmodule.so
drwxr-xr-x  2 root root   4096 Nov  6  2014 paramiko
lrwxrwxrwx  1 root root     49 Mar 28  2013 paramiko-1.7.7.1.egg-info -> ../../../share/pyshared/paramiko-1.7.7.1.egg-info
drwxr-xr-x  4 root root   4096 Dec 14 20:59 pip
drwxr-xr-x  2 root root   4096 Dec 14 20:58 pip-1.0.egg-info
lrwxrwxrwx  1 root root     40 Oct 22  2011 pkg_resources.py -> ../../../share/pyshared/pkg_resources.py
-rw-r--r--  1 root root  94800 Nov  6  2014 pkg_resources.pyc
lrwxrwxrwx  1 root root     41 Oct 30  2014 problem_report.py -> ../../../share/pyshared/problem_report.py
-rw-r--r--  1 root root  15479 Nov  6  2014 problem_report.pyc
lrwxrwxrwx  1 root root     47 Jun 27  2012 pycrypto-2.4.1.egg-info -> ../../../share/pyshared/pycrypto-2.4.1.egg-info
lrwxrwxrwx  1 root root     46 Dec 30  2011 pycurl-7.19.0.egg-info -> ../../../share/pyshared/pycurl-7.19.0.egg-info
-rw-r--r--  1 root root  68880 Dec 30  2011 pycurl.so
lrwxrwxrwx  1 root root     47 Sep 23  2013 pyOpenSSL-0.12.egg-info -> ../../../share/pyshared/pyOpenSSL-0.12.egg-info
lrwxrwxrwx  1 root root     45 Dec 30  2011 pyserial-2.5.egg-info -> ../../../share/pyshared/pyserial-2.5.egg-info
-rw-r--r--  1 root root 447336 Sep 13  2013 pysss.so
lrwxrwxrwx  1 root root     58 Jan 24  2014 python_apt-0.8.3ubuntu7.2.egg-info -> ../../../share/pyshared/python_apt-0.8.3ubuntu7.2.egg-info
drwxr-xr-x  2 root root   4096 Nov  6  2014 python_debian-0.1.21ubuntu1.egg-info
lrwxrwxrwx  1 root root     44 Dec 16  2011 PyYAML-3.10.egg-info -> ../../../share/pyshared/PyYAML-3.10.egg-info
-rw-r--r--  1 root root    119 Oct 26 14:35 README
drwxr-xr-x  2 root root   4096 Nov  6  2014 serial
drwxr-xr-x  4 root root   4096 Dec 14 20:59 setuptools
lrwxrwxrwx  1 root root     43 Oct 22  2011 setuptools.egg-info -> ../../../share/pyshared/setuptools.egg-info
lrwxrwxrwx  1 root root     38 Oct 22  2011 setuptools.pth -> ../../../share/pyshared/setuptools.pth
drwxr-xr-x  3 root root   4096 Nov  6  2014 simplejson
lrwxrwxrwx  1 root root     49 Jan 30  2012 simplejson-2.3.2.egg-info -> ../../../share/pyshared/simplejson-2.3.2.egg-info
lrwxrwxrwx  1 root root     31 Oct 22  2011 site.py -> ../../../share/pyshared/site.py
-rw-r--r--  1 root root   1725 Dec 14 20:59 site.pyc
-rw-r--r--  1 root root  34912 Feb  9  2012 _snackmodule.so
lrwxrwxrwx  1 root root     32 Feb  9  2012 snack.py -> ../../../share/pyshared/snack.py
-rw-r--r--  1 root root  39925 Nov  6  2014 snack.pyc
drwxr-xr-x  2 root root   4096 Nov  6  2014 softwareproperties
lrwxrwxrwx  1 root root     37 Sep 13  2013 SSSDConfig.py -> ../../../share/pyshared/SSSDConfig.py
-rw-r--r--  1 root root  64074 Nov  7  2014 SSSDConfig.pyc
lrwxrwxrwx  1 root root     46 Sep 13  2013 sssd_upgrade_config.py -> ../../../share/pyshared/sssd_upgrade_config.py
-rw-r--r--  1 root root  14614 Nov  7  2014 sssd_upgrade_config.pyc
drwxr-xr-x 13 root root   4096 Nov  6  2014 tests
drwxr-xr-x 16 root root   4096 Nov  7  2014 twisted
lrwxrwxrwx  1 root root     52 Mar  9  2012 Twisted_Core-11.1.0.egg-info -> ../../../share/pyshared/Twisted_Core-11.1.0.egg-info
drwxr-xr-x  2 root root   4096 Nov  6  2014 ufw
lrwxrwxrwx  1 root root     45 Apr  5  2012 ufw-0.31.1_1.egg-info -> ../../../share/pyshared/ufw-0.31.1_1.egg-info
lrwxrwxrwx  1 root root     56 Nov 14  2012 unattended_upgrades-0.1.egg-info -> ../../../share/pyshared/unattended_upgrades-0.1.egg-info
drwxr-xr-x  3 root root   4096 Nov  6  2014 UpdateManager
lrwxrwxrwx  1 root root     35 Dec 30  2011 validate.py -> ../../../share/pyshared/validate.py
-rw-r--r--  1 root root  46734 Nov  6  2014 validate.pyc
drwxr-xr-x  3 root root   4096 Nov  6  2014 wadllib
drwxr-xr-x  2 root root   4096 Nov  6  2014 wadllib-1.3.0.egg-info
drwxr-xr-x  2 root root   4096 Nov  6  2014 xapian
drwxr-xr-x  2 root root   4096 Nov  6  2014 yaml
-rw-r--r--  1 root root 185456 Dec 16  2011 _yaml.so
drwxr-xr-x  3 root root   4096 Nov  6  2014 zope
drwxr-xr-x  2 root root   4096 Nov  6  2014 zope.interface-3.6.1.egg-info
lrwxrwxrwx  1 root root     54 Dec 31  2011 zope.interface-3.6.1-nspkg.pth -> ../../../share/pyshared/zope.interface-3.6.1-nspkg.pth

但是/usr/local/lib/python2.7/dist-packages中的新模块只能使用/ usr / bin / python(仍为2.7.3)导入。

使用默认的python(/ usr / local / bin / python,2.7.6)是我想要运行的版本,但是没有看到要导入的模块。

我做错了什么(我应该升级而不是wget / make / install吗?)

我现在该如何解决?

1 个答案:

答案 0 :(得分:0)

好问题,拥有日志和信息很好:)

如果我理解正确,那么模块是不是安装到你想要的Python版本?

若是,请尝试:

  1. 导航到要将模块安装到的Python目录。
  2. 然后从Python目录导航到Scripts/文件夹。 (所以你的目录应该是/usr/lib/python<Python Version>/Scripts/
  3. 现在运行sudo python pip.py install <Module Name>
  4. 现在模块应该直接安装到那个Python版本。

    如果这不是您要找的答案,请发表评论。

    希望这有帮助!