我有一个使用bcrypt的程序,如果用户没有bcrypt,我想安装该软件包。它可以在我的PC上运行Python 3.7和最新版本的pip,但在学校时可以在标题中输入错误。这是相关代码:
try:
import bcrypt
except ImportError:
from pip._internal import main as pip # if bcrypt cannot be installed, attempt installation
print("Attempting to install bcrypt...")
pip(["install","bcrypt"])
这是错误:
Traceback (most recent call last):
File "\\ths-fs-002\Student Work\2016\16HarveyJ\NEA-1\src\main.py", line 9, in <module>
from pip._internal import main as pip # if bcrypt cannot be installed, attempt installation
File "C:\Python34\lib\site-packages\pip\__init__.py", line 9, in <module>
from pip.log import logger
File "C:\Python34\lib\site-packages\pip\log.py", line 8, in <module>
from pip import backwardcompat
File "C:\Python34\lib\site-packages\pip\backwardcompat\__init__.py", line 27, in <module>
console_encoding = sys.__stdout__.encoding
AttributeError: 'NoneType' object has no attribute 'encoding'