Ubuntu 手动安装pycrypto

首先查看自己python版本,是python2.7

然后打开终端,输入命令sudo su进入root权限

pip install pycrypto

安装完是在/usr/local/lib/python2.7/dist-packages/Crypto

(如果是python3 是pip3 install pycrypto,路径应该是usr/local/lib/python3/dist-packages/Crypto)

如果没有安装pip,参考https://www.cnblogs.com/twtp/p/5325649.html

1、经过以安装python2.7.9 和pycrypto努力后,编译optee的时候还是会有报错

ImportError: No module named Crypto.Signature

决定删掉一切重新再来

1、

一开始装了3.5的

1.卸载python3.5

sudo apt-get remove python3.5

2.卸载python3.5以及它的依赖包

sudo apt-get remove --auto-remove python3.5

3.清除python3.5

要想清除python3.5的配置文件和数据文件,执行以下命令:

sudo apt-get purge python3.5

sudo apt-get purge --auto-remove python3.5

2、然后把python 也卸载了

sudu apt-get remove python

3、重新安装python2.7.9

参照python在ubuntu中的几种安装方法 源码安装方法 

4、安装pip

sudo apt-get pip

5、在StackOverflow上找到如下资料参考安装pycrypto

I had the same problem on my Mac when installing with pip. I then removed pycrypto and installed it again with easy_install, like this:

pip uninstall pycrypto

easy_install pycrypto

also as Luke commented: If you have trouble running these commands, be sure to run them as admin (sudo)

Hope this helps!

来自

sudo pip install pycrypto

来自

==》然而我这边安装报错了,错误如下,不过别怕 接下来还有

root@kjdmstar:/home/kjd-mstar# sudo pip install pycrypto

Downloading/unpacking pycrypto

  Cannot fetch index base URL http://pypi.python.org/simple/

  Could not find any downloads that satisfy the requirement pycrypto

No distributions at all found for pycrypto

Storing complete log in /root/.pip/pip.log

root@kjdmstar:/home/kjd-mstar# easy_install pycrypto   

Searching for pycrypto

Reading http://pypi.python.org/simple/pycrypto/

Couldn't find index page for 'pycrypto' (maybe misspelled?)

Scanning index of all packages (this may take a while)

Reading http://pypi.python.org/simple/

No local packages or download links found for pycrypto

error: Could not find suitable distribution for Requirement.parse('pycrypto')

6、于是自己手动代开 https://pypi.org/simple/pycrypto/ 去上面看看 ,结果发现有对应的tar包可以下载,于是下载看看能否手动安装

我下载的是这份 pycrypto-2.6.1.tar.gz

下载解压后先看README

The modules are packaged using the Distutils, so you can simply run

"python setup.py build" to build the package, and "python setup.py

install" to install it.

所以执行下命令就可以了

cd对应源码目录

./configure

python setup.py build

python setup.py install

安装的目录也是我自己手动安装python2.7.9下,如下,测试OK,所以之前没有效果看起来是跟系统自带的python冲突了

Writing /usr/local/lib/python2.7/site-packages/pycrypto-2.6.1-py2.7.egg-info

你可能感兴趣的:(Ubuntu 手动安装pycrypto)