Python import random报错处理办法
【转自】http://blog.chinaunix.net/uid-26000296-id-4356738.html
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 "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.6/random.py", line 48, in <module>
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包重新下了一遍)。。。
感谢原文的分享啊,不然还不知道要纠结多久。
Python import random报错处理办法的更多相关文章
- Python Django migrate 报错解决办法
1. 在现有基础上又添加一个表的时候migrate报错 migrate报错django.db.utils.OperationalError: (1050, "Table 'cmdb_eidc ...
- Linux Python import jenkins 报错 oserror: /usr/lib/python2.7/site-packages/lookup3.so
安装了jenkins和Python-jenkins后,在脚本中import jenkins会报错:oserror: /usr/lib/python2.7/site-packages/lookup3.s ...
- python安装OpenCV后import cv2报错解决办法
现在python安装完成后,运行pip install opencv-python安装成功后,import cv2时会失败 看到有人给出下载https://www.lfd.uci.edu/~gohlk ...
- python import win32clipboard 报错DLL load failed: %1 不是有效的 Win32 应用程序。
在python中引入win32clipboard时报错,DLL load failed: %1 不是有效的 Win32 应用程序 >>> import win32clipboardT ...
- Python中from scipy.misc import imread报错的原因?
from scipy.misc import imread 报错 查询后其原因是from scipy.misc import imread,imwrite 等方法已经被弃用,Python已经将imre ...
- pycharm 中 import requests 报错
一 , 使用Pycharm来抓取网页的时候,要导入requests模块,但是在pycharm中 import requests 报错. 原因: python中还没有安装requests库 解决办法: ...
- Aasible中cryptography兼容性报错解决办法
Aasible中cryptography兼容性报错解决办法 1 Ansible中使用ansible --version查看版本,报错信息如下: ERROR! Unexpected Exception, ...
- import cx_Oracle报错,提示importError: DLL load failed: 不是有效的Win32程序。
问题说明1:WIN32,python是2.7版本,本地oracle client是32位的.import cx_Oracle报错,提示importError: DLL load failed: 该模块 ...
- 在cmd下import cv2报错——OpenCV实现BRISK
平台:win10 x64 +JetBrains PyCharm 2018.2.4 x64 +Anaconda3(python3.7.0+opencv3.4.5) Issue说明:同学发了个python ...
随机推荐
- oracle 建表时显示ORA-00904无效的标识符
oracle 建表时显示ORA-00904无效的标识符 CreationTime--2018年7月19日16点03分 Author:Marydon 1.情景展示 使用plsql建表时,报错 字段展 ...
- .NET 垃圾回收机制要点整理
1. .NET资源分托管资源和非托管资源,对于托管资源,.NET GC可以很好的回收无用的垃圾,而对于非托管(例如文件访问,网络访问等)需要手动清理垃圾(显式释放). 2. 非托管资源的释放,.NET ...
- raise语句
# -*- coding: utf-8 -*- #python 27 #xiaodeng #Python学习手册 868 #raise语句 res=[IndexError,TypeError] #ra ...
- logging日志管理--将日志打印在屏幕上
# -*- coding: cp936 -*- # test.py #http://blog.chinaunix.net/uid-27571599-id-3492860.html #logging日志 ...
- elasticsearch5.4体验
Elasticsearch是基于Lucene分布式.实时查询的搜索分析引擎.我目前应用在日志集中化处理上... 01.下载elasticsearch5.4 https://www.elasti ...
- 微信小程序基于swiper组件的tab切换
代码地址如下:http://www.demodashi.com/demo/14010.html 一.前期准备工作 软件环境:微信开发者工具 官方下载地址:https://mp.weixin.qq.co ...
- PHP生成缩略图、加水印
<?php class ThumbWaterImages{ /** * 生成缩略图/加水印 * classname ThumbWaterImages * datetime:2015-1-15 * ...
- [转]TCP(HTTP)长连接和短连接区别和怎样维护长连接
原文链接 一.HTTP协议和TCP协议 HTTP的长连接和短连接本质上是TCP长连接和短连接.HTTP属于应用层协议,在传输层使用TCP协议,在网络层使用IP协议.IP协议主要解决网络路由和寻址问题, ...
- Android 报错:Conversion to Dalvik format failed: Unable to execute dex: java.nio.BufferOverflowException. Check the Eclipse log for stack trace.
在android高版本开发环境(sdk 4.4)导入低版本(sdk 3.0)的工程时编译报错,报错信息如:Conversion to Dalvik format failed: Unable to e ...
- Singleton - 单例模式和Double-Checked Locking - 双重检查锁定模式
问题描述 现在,不管开发一个多大的系统(至少我现在的部门是这样的),都会带一个日志功能:在实际开发过程中,会专门有一个日志模块,负责写日志,由于在系统的任何地方,我们都有可能要调用日志模块中的函数,进 ...