当前位置: 首页 > 工具软件 > PyCrypto > 使用案例 >

pycrypto

凤高翰
2023-12-01

安装命令:


        Python3.exe -m pip install  pycrypto

1、问题描述:


File "d:/apply/python362/lib/site-packages/pip/compat_init_.py", line 73, in console_to_str
return s.decode(sys.stdout.encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd3 in position 94: invalid continuation byte


解决方法有两个,可以任选其一:


(1)修改python362/lib/site-packages/pip/compat_init_.py文件的第75行


def console_to_str(s):
try:
return s.decode(sys.__stdout__.encoding)
except UnicodeDecodeError:
return s.decode('utf-8')


def console_to_str(s):
try:
result = s.decode(sys.__stdout__.encoding)
except UnicodeDecodeError:
import locale
s = s.decode(locale.getpreferredencoding(), 'ignore').encode('utf-8')
result = s.decode('utf-8')
return result

(2)修改python362/lib/site-packages/pip/compat_init_.py文件的第75行


def console_to_str(s):
try:
return s.decode(sys.__stdout__.encoding)
except UnicodeDecodeError:
return s.decode('utf-8')

   我用的这个地方修改 73行 但文件不是这个,改成这个就行了  cp936
def console_to_str(s):
try:
return s.decode(sys.__stdout__.encoding)
except UnicodeDecodeError:
try:
return s.decode('utf-8')
except UnicodeDecodeError:
return s.decode('cp936')

2、问题描述:


winrand.c
C:/Program Files (x86)/Windows Kits/10/include/10.0.15063.0/ucrt/inttypes.h(26): error C2061: 语法错误: 标识符“intmax_t”
C:/Program Files (x86)/Windows Kits/10/include/10.0.15063.0/ucrt/inttypes.h(27): error C2061: 语法错误: 标识符“rem”
C:/Program Files (x86)/Windows Kits/10/include/10.0.15063.0/ucrt/inttypes.h(27): error C2059: 语法错误:“;”
C:/Program Files (x86)/Windows Kits/10/include/10.0.15063.0/ucrt/inttypes.h(28): error C2059: 语法错误:“}”
C:/Program Files (x86)/Windows Kits/10/include/10.0.15063.0/ucrt/inttypes.h(30): error C2061: 语法错误: 标识符“imaxdiv_t”
C:/Program Files (x86)/Windows Kits/10/include/10.0.15063.0/ucrt/inttypes.h(30): error C2059: 语法错误:“;”
C:/Program Files (x86)/Windows Kits/10/include/10.0.15063.0/ucrt/inttypes.h(40): error C2143: 语法错误: 缺少“{”(在“__cdecl”的前面)
C:/Program Files (x86)/Windows Kits/10/include/10.0.15063.0/ucrt/inttypes.h(41): error C2146: 语法错误: 缺少“)”(在标识符“_Number”的 前面)
C:/Program Files (x86)/Windows Kits/10/include/10.0.15063.0/ucrt/inttypes.h(41): error C2061: 语法错误: 标识符“_Number”
C:/Program Files (x86)/Windows Kits/10/include/10.0.15063.0/ucrt/inttypes.h(41): error C2059: 语法错误:“;”
C:/Program Files (x86)/Windows Kits/10/include/10.0.15063.0/ucrt/inttypes.h(42): error C2059: 语法错误:“)”
C:/Program Files (x86)/Windows Kits/10/include/10.0.15063.0/ucrt/inttypes.h(45): error C2143: 语法错误: 缺少“{”(在“__cdecl”的前面)
C:/Program Files (x86)/Windows Kits/10/include/10.0.15063.0/ucrt/inttypes.h(46): error C2146: 语法错误: 缺少“)”(在标识符“_Numerator”的前面)
C:/Program Files (x86)/Windows Kits/10/include/10.0.15063.0/ucrt/inttypes.h(46): error C2061: 语法错误: 标识符“_Numerator”
C:/Program Files (x86)/Windows Kits/10/include/10.0.15063.0/ucrt/inttypes.h(46): error C2059: 语法错误:“;”
C:/Program Files (x86)/Windows Kits/10/include/10.0.15063.0/ucrt/inttypes.h(46): error C2059: 语法错误:“,”
C:/Program Files (x86)/Windows Kits/10/include/10.0.15063.0/ucrt/inttypes.h(48): error C2059: 语法错误:“)”
C:/Program Files (x86)/Windows Kits/10/include/10.0.15063.0/ucrt/inttypes.h(50): error C2143: 语法错误: 缺少“{”(在“__cdecl”的前面)
C:/Program Files (x86)/Windows Kits/10/include/10.0.15063.0/ucrt/inttypes.h(56): error C2143: 语法错误: 缺少“{”(在“__cdecl”的前面)
C:/Program Files (x86)/Windows Kits/10/include/10.0.15063.0/ucrt/inttypes.h(63): error C2143: 语法错误: 缺少“{”(在“__cdecl”的前面)
C:/Program Files (x86)/Windows Kits/10/include/10.0.15063.0/ucrt/inttypes.h(69): error C2143: 语法错误: 缺少“{”(在“__cdecl”的前面)
C:/Program Files (x86)/Windows Kits/10/include/10.0.15063.0/ucrt/inttypes.h(76): error C2143: 语法错误: 缺少“{”(在“__cdecl”的前面)
C:/Program Files (x86)/Windows Kits/10/include/10.0.15063.0/ucrt/inttypes.h(82): error C2143: 语法错误: 缺少“{”(在“__cdecl”的前面)
C:/Program Files (x86)/Windows Kits/10/include/10.0.15063.0/ucrt/inttypes.h(89): error C2143: 语法错误: 缺少“{”(在“__cdecl”的前面)
C:/Program Files (x86)/Windows Kits/10/include/10.0.15063.0/ucrt/inttypes.h(95): error C2143: 语法错误: 缺少“{”(在“__cdecl”的前面)
error: command 'D://Program Files (x86)//Microsoft Visual Studio//2017//Community//VC//Tools//MSVC//14.10.25017//bin//HostX64//x64//cl.exe' failed with exit status 2

解决方法有两个,可以任选其一:


(1)本机上安装了Microsoft Visual Studio2017 Community版


A、将D:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.10.25017/include/stdint.h文件拷贝到C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/ucrt/目录下


B、修改C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/ucrt/inttypes.h中的第13行,将


#include 

修改为


#include "stdint.h"

(2)使用环境变量(未验证)


设置环境变量VCINSTALLDIR为D:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC
set CL=/FI "%VCINSTALLDIR/Tools/MSVC/14.10.25017/include/stdint.h" %CL%
然后执行pip install pycrypto


 类似资料: