python import random 报错_Python import random报错处理办法

python安装失败:make的时候报错:

/usr/include/tkDecls.h:1542: error: expected ‘)’ before ‘*’ token

/usr/include/tkDecls.h:1639: error: expected declaration specifiers or ‘...’ before ‘Drawable’

/usr/include/tkDecls.h:1674: error: expected ‘)’ before ‘*’ token

/usr/include/tkDecls.h:1679: error: expected ‘)’ before ‘*’ token

/usr/include/tkDecls.h:1710: error: expected specifier-qualifier-list before ‘XColor’

Failed to find the necessary bits to build these modules:

bsddb185 dl imageop

sunaudiodev

To find the necessary bits, look in setup.py in detect_modules() for the module's name.

Failed to build these modules:

_tkinter binascii zlib

上述错误,导致的结果是:

[storm@bs035 rpm]$ python

Python 2.6.6 (r266:84292, Apr 12 2016, 18:51:29)

[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>> import random

Traceback (most recent call last):

File "", line 1, in

File "/usr/local/lib/python2.6/random.py", line 48, in

from binascii import hexlify as _hexlify

ImportError: No module named binascii

>>>

解决办法

python版本不正常导致的。

升级安装zlib

# wget http://sourceforge.net/projects/libpng/files/zlib/1.2.8/zlib-1.2.8.tar.gz

# tar -zxvf zlib-1.2.8.tar.gz

# cd zlib-1.2.8

# ./configure

# make install

升级安装sqlite3

# cd ..

# wget http://www.sqlite.org/2014/sqlite-autoconf-3080500.tar.gz

# tar -zxvf sqlite-autoconf-3080500.tar.gz

# cd sqlite-autoconf-3080500

# ./configure

# make

# make install

# cd ../Python-2.7.3

# make –s

# make && sudo make install

MD,之前可能删过linux自带的rpm包。

血淋淋的教训啊,搞这个东东,搞了接近一天(先是一个个找rpm包,然后又按照正常的机器上装的rpm包重新下了一遍)。。。

感谢原文的分享啊,不然还不知道要纠结多久。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值