欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

ubuntu 16.04 安装 python2.7 以及 cv2, dist-package 和 site-package 的区别, import cv2 出问题解答

程序员文章站 2024-01-05 15:27:28
...

ubuntu16.04默认安装python3以上,需要手动安装2.7。

1、先确保make、gcc、g++已经安装好,如果没有则需要先安装这三个程序,均使用apt-get的方式直接装;

2、下载python2.7包:

  wget https://www.python.org/ftp/python/2.7.13/Python-2.7.13.tgz

3、解压该包:

  tar -xvf Python-2.7.13.tgz

4、进入该包:

  cd Python-2.7.13

5、./configure

6、make

7、make install

安装完毕,如果因为权限问题失败,需要加sudo。


  1. sudo apt-get install 安装的package存放在 /usr/lib/python2.7/dist-packages目录中
  2. pip 或者 easy_install安装的package存放在/usr/local/lib/python2.7/dist-packages目录中
  3. 手动从源代码安装的package存放在site-packages目录中

The dist-packages is a Debian-specific convention that is also present in its derivatives, like Ubuntu. Modules are installed to dist-packages when they come from the Debian package manager into this location:

/usr/lib/python2.7/dist-packages

Since easy_install and pip are installed from the package manager, they also use dist-packages, but they put packages here:

/usr/local/lib/python2.7/dist-packages

From the Debian Python Wiki:

dist-packages instead of site-packages. Third party Python software installed from Debian packages goes into dist-packages, not site-packages. This is to reduce conflict between the system Python, and any from-source Python build you might install manually.

This means that if you manually install Python from source, it uses the site-packages directory. This allows you to keep the two installations separate, especially since Debian and Ubuntu rely on the system version of Python for many system utilities.


cv2:

pip install opencv-python

import cv2 出问题解决:

sudo ldconfig

http://blog.sina.com.cn/s/blog_4ddef8f80102v57b.html

http://www.cnblogs.com/world-for-gold/p/6837782.html

上一篇:

下一篇: