计算机安装了Python3.8,安装myqr出错。输入pip install myqr后如下图显示 错在哪里,怎么解决?
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了计算机安装了Python3.8,安装myqr出错。输入pip install myqr后如下图显示 错在哪里,怎么解决?相关的知识,希望对你有一定的参考价值。
前面是这样的:C:\Users\Administrator>pip install myqrCollecting myqr WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)")': /simple/myqr/ Downloading https://files.pythonhosted.org/packages/ec/ce/5ff57cde76feaa193978a28097edbb1c649e1f439182649eb9ecc7b86a03/MyQR-2.3.1.zip后面看也还在正常下载:有进度的 过会就是红色的字显示如下了 |█████████████████ | 1.7MB 163bytes/s eta 2:39:47ERROR: Exception:Traceback (most recent call last): File "d:\pyth\lib\site-packages\pip\_vendor\urllib3\response.py", line 397, in _error_catcher yield File "d:\pyth\lib\site-packages\pip\_vendor\urllib3\response.py", line 479, in read data = self._fp.read(amt) File "d:\pyth\lib\site-packages\pip\_vendor\cachecontrol\filewrapper.py", line 62, in read data = self.__fp.read(amt) File "d:\pyth\lib\http\client.py", line 454, in read n = self.readinto(b) File "d:\pyth\lib\http\client.py", line 498, in readinto n = self.fp.readinto(b) File "d:\pyth\lib\socket.py", line 669, in readinto return self._sock.recv_into(b) File "d:\pyth\lib\ssl.py", line 1241, in recv_into return self.read(nbytes, buffer) File "d:\pyth\lib\ssl.py", line 1099, in read return self._sslobj.read(len, buffer)socket.timeout: The read operation timed outDuring handling of the above exception, another exception occurred:Traceback (most recent call last): File "d:\pyth\lib\site-packages\pip\_internal\cli\base_command.py", line 188,in main status = self.run(options, args) File "d:\pyth\lib\site-packages\pip\_internal\commands\install.py", line 345,in run……………………
谢谢,请问这个怎么更换吗?忘指教。
追答Windows更改pip镜像源
(1)在windows文件管理器中,输入 %APPDATA%
(2)会定位到一个新的目录下,在该目录下新建pip文件夹,然后到pip文件夹里面去新建个pip.ini文件
(3)在新建的pip.ini文件中输入以下内容
[global]
timeout = 6000
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
trusted-host = https://pypi.tuna.tsinghua.edu.cn/simple
使用python3调用MyQR库生成动态二维码(附源代码)
可生成普通二维码、带图片的艺术二维码(黑白与彩色)、动态二维码(黑白与彩色)。
GitHub:https://github.com/sylnsfar/qrcode
中文版:https://github.com/sylnsfar/qrcode/blob/master/README-cn.md
已封装成MyQR库,直接使用pip安装即可
# 安装模块后 from MyQR import myqr version, level, qr_name = myqr.run( words, version=1, level=\'H\', picture=None, colorized=False, contrast=1.0, brightness=1.0, save_name=None, save_dir=os.getcwd() )
参数介绍:
# help(myqr) Positional parameter words: str Optional parameters version: int, from 1 to 40 level: str, just one of (\'L\',\'M\',\'Q\',\'H\') picutre: str, a filename of a image colorized: bool constrast: float brightness: float save_name: str, the output filename like \'example.png\' save_dir: str, the output directory
words:字符串类型,链接或者句子作为参数,然后在程序的当前目录中产生相应的二维码图片文件
version:整型,控制边长,范围是1至40,数字越大边长越大
level:字符串类型,控制纠错水平,范围是L、M、Q、H,从左到右依次升高
picture:字符串类型,图片链接,支持png、jpg、bmp、gif(用gif格式的话,生成的二维码就是动态的)
colorized:布尔类型,True是彩色,False是黑白
save_name:字符串类型,保存二维码图片的名字,需要写出图片类型。默认输出文件名是“ qrcode.png ",而默认存储位置是当前目录,重名会覆盖当前
save_dir:字符串类型,保存二维码图片的路径
constrast:浮点类型,调节生成图片的对比度,1.0表示与原图片一致,更小的值表示更低的对比度
brightness:浮点类型,调节生成图片的亮度,用法与constrast一致
源代码
from MyQR import myqr
import os
#1、黑白、L,其他参数默认
version, level, qr_name = myqr.run(
words=\'https://github.com/sylnsfar/qrcode/blob/master/README-cn.md\' ,
version=1,
level=\'L\',
picture=\'panda.png\',
colorized=False,
contrast=1.0,
brightness=1.0,
save_name=\'1panda_noncolorized.png\',
save_dir=os.getcwd()
)
#2、彩色、L,其他参数默认
version, level, qr_name = myqr.run(
words=\'https://github.com/sylnsfar/qrcode/blob/master/README-cn.md\' ,
version=1,
level=\'L\',
picture=\'panda.png\',
colorized=True,
contrast=1.0,
brightness=1.0,
save_name=\'2panda_colorized.png\',
save_dir=os.getcwd()
)
#3、彩色、H,其他参数默认
version, level, qr_name = myqr.run(
words=\'https://github.com/sylnsfar/qrcode/blob/master/README-cn.md\' ,
version=1,
level=\'H\',
picture=\'panda.png\',
colorized=True,
contrast=1.0,
brightness=1.0,
save_name=\'3panda_colorized_H.png\',
save_dir=os.getcwd()
)
#4、彩色、H、40,其他参数默认
version, level, qr_name = myqr.run(
words=\'https://github.com/sylnsfar/qrcode/blob/master/README-cn.md\' ,
version=40,
level=\'H\',
picture=\'panda.png\',
colorized=True,
contrast=1.0,
brightness=1.0,
save_name=\'4panda_colorized_H_40.png\',
save_dir=os.getcwd()
)
#5、彩色、动态二维码,其他参数默认
version, level, qr_name = myqr.run(
words=\'https://github.com/sylnsfar/qrcode/blob/master/README-cn.md\' ,
version=1,
level=\'L\',
picture=\'qb.gif\',
colorized=True,
contrast=1.0,
brightness=1.0,
save_name=\'5qb.gif\',
save_dir=os.getcwd()
)
原始图片:panda.png,大小1213*1213
结果(按顺序显示,未改显示图片的大小)
有几个小问题:
1. 原图本身是jpg格式,但是运行报错;将后缀改为png之后运行ok,原因暂时未知
2.生成的二维码大小要适中,若version过大(例如本例中的第四张),手机需要距离一定的距离才能扫到,但是无法识别
3.原图最好使用正方形图片
以上是关于计算机安装了Python3.8,安装myqr出错。输入pip install myqr后如下图显示 错在哪里,怎么解决?的主要内容,如果未能解决你的问题,请参考以下文章
电脑已经安装python3.8版本,之前做好py文件为啥打不开,求各位大神看一下