win8安装python3后不能编程_解决python在windows8.1 64位下的各种疑难杂症

由于工作上要用python进行数据采集和文本分析,鄙人又是软件只用最新版的狂人,于是在windows8 64位下配置python走上了一条不归路,以下是不归路的一些经验。

1.Python在windows7/8下安装Setuptools,执行ez_setup.py进行安装时会发生错误,提示编码问题导致异常

解决办法:编辑Python安装目录下的mimetypes.py文件,在文件中对应位置增加【3-6行】的部分内容

import os

import sys

#the following two line solve the "python ez_setup.py" install error

reload(sys)

sys.setdefaultencoding('gb18030')

#end

import posixpath

import urllib

2.安装插件后import导入提示:ImportError: DLL load failed: %1 不是有效的 Win32 应用程序。

解决办法:安装64位的插件,部分64位的插件可以在下面这个网站上找到:http://www.lfd.uci.edu/~gohlke/pythonlibs/#libxml-python

3.安装第三方库出现 Python version 2.7 required, which was not found in the registr。

解决办法:建立一个文件 register.py ,内容如下.,然后执行该脚本。

import sys

from _winreg import *

# tweak as necessary

version = sys.version[:3]

installpath = sys.prefix

regpath = "SOFTWARE\Python\Pythoncore\%s\" % (version)

installkey = "InstallPath"

pythonkey = "PythonPath"

pythonpath = "%s;%s\Lib\;%s\DLLs\" % (

installpath, installpath, installpath

)

def RegisterPy():

try:

reg = OpenKey(HKEY_CURRENT_USER, regpath)

except EnvironmentError as e:

try:

reg = CreateKey(HKEY_CURRENT_USER, regpath)

SetValue(reg, installkey, REG_SZ, installpath)

SetValue(reg, pythonkey, REG_SZ, pythonpath)

CloseKey(reg)

except:

print "*** Unable to register!"

return

print "--- Python", version, "is now registered!"

return

if (QueryValue(reg, installkey) == installpath and

QueryValue(reg, pythonkey) == pythonpath):

CloseKey(reg)

print "=== Python", version, "is already registered!"

return

CloseKey(reg)

print "*** Unable to register!"

print "*** You probably have another Python installation!"

if __name__ == "__main__":

RegisterPy()

4.安装一些模块时,提示:Python error: Unable to find vcvarsall.bat

解决办法:安装Vs2008 64位版,没错!就是Microsoft Visual Studio 2008 X64!记得安装的时候,勾选 Visual C++下面的“X64编译器和工具”的选项!当然也有安装MinGW或者安装VS2010,不过都需要配置,安装VS2008是最简单的。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值