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 ...
随机推荐
- flume spooldir bug修复
BUG:在往目录中copy大文件时,没有复制完,flume就开始读-->导致报错 在代码中体现为:org.apache.flume.client.avro.ReliableSpoolingFil ...
- jersey获取各个参数的总结
service端: @Path("/hello") public class HelloService { @GET @Produces("text/plain" ...
- exception javax.crypto.BadPaddingException: Given final block not properly padded
exception javax.crypto.BadPaddingException: Given final block not properly padded CreationTime--20 ...
- coding云(git)远程创建版本库和上传文件
1.创建项目不讲,注意勾选 README选项 2.本地需要首先安装 windows 的git库,https://gitforwindows.org/ 3.进入www目录下,直接将coding云上的项目 ...
- Mybatis日期类型的关系判断
进行时间段的查询时,在mapper文件中直接使用">","<"等关系运算符是无法解析的 <if test="executeStart ...
- Web Service——CXF+Spring 整合
结合spring框架来实现CXF发布SOAP协议的服务,步骤基本相同,所不同的是的多了一些配置项,步骤如下 1. 服务端 第一步:创建web项目(引入jar包) 第二步:创建SEI接口 import ...
- 一、springMVC、freemarker页面半自动静态化
说明:刚刚接到公司的通知,实现(半自动化),即通过参数控制是否需要静态化页面(哪里我说错了,勿喷!谢谢) 1,请求.do的URL时直接生成对应的.htm文件,并将请求转发到该htm文件 2,自由控制某 ...
- python matplotlib.pyplot画矩形图 以及plt.gca()
plt的Rectangle参数: 第一个参数是坐标(x,y),即矩形的画图的起点坐标,这个起点坐标不是一味地从左下角开始画,而是对应整个图中坐标原点,即(0,0). 第二个参数是矩形宽度 第三个坐标是 ...
- FA_资产成批报废(流程)
2014-06-08 Created By BaoXinjian
- Linux中断 - IRQ number和中断描述符
一.前言 本文主要围绕IRQ number和中断描述符(interrupt descriptor)这两个概念描述通用中断处理过程.第二章主要描述基本概念,包括什么是IRQ number,什么是中断描述 ...