『瀚思彼岸』» 智能家居技术论坛

 找回密码
 立即注册
查看: 5210|回复: 1

[已解决] win10安装pycrypto

[复制链接]

219

主题

1287

帖子

7951

积分

超级版主

Rank: 8Rank: 8

积分
7951
金钱
6634
HASS币
86

教程狂人论坛风云人物突出贡献

发表于 2018-2-9 15:42:42 | 显示全部楼层 |阅读模式

安装命令:


        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

参考文档:
http://blog.csdn.net/xiajing13579/article/details/78593049

回复

使用道具 举报

123

主题

4664

帖子

1万

积分

管理员

囧死

Rank: 9Rank: 9Rank: 9

积分
16442
金钱
11693
HASS币
45
发表于 2018-2-10 12:15:12 | 显示全部楼层
有技术含量!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-12-23 18:31 , Processed in 0.203575 second(s), 24 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表