-
首先你电脑确保已经安装了Python,并且在系统的环境变量里面的Path加入了Python的安装地址,最后的结果就是能在“开始”-》“cmd”-->"Python"回车的时候能正常显示Python的版本信息。然后已经从网上下载了ez_setup.py文件(下载进入https://pypi.python.org/pypi/setuptools/)
-
然后在cmd进入命令行窗口, 进入ez_setup.py目录,我这里是下载放置在F盘,然后输入命令:python ez_setup.py 系统就会自动下载setuptools工具安装,最后的结局是显示编码错误:
F:\>python ez_setup.py
Extracting in c:\users\yc_00001\appdata\local\temp\tmpujxuqp
Now working in c:\users\yc_00001\appdata\local\temp\tmpujxuqp\setuptools-7.0
Installing Setuptools
Traceback (most recent call last):
File "setup.py", line 19, in <module>
exec(init_file.read(), command_ns)
File "<string>", line 11, in <module>
File "c:\users\yc_00001\appdata\local\temp\tmpujxuqp\setuptools-7.0\setuptools
\__init__.py", line 12, in <module>
from setuptools.extension import Extension
File "c:\users\yc_00001\appdata\local\temp\tmpujxuqp\setuptools-7.0\setuptools
\extension.py", line 8, in <module>
from .dist import _get_unpatched
File "c:\users\yc_00001\appdata\local\temp\tmpujxuqp\setuptools-7.0\setuptools
\dist.py", line 16, in <module>
from setuptools.depends import Require
File "c:\users\yc_00001\appdata\local\temp\tmpujxuqp\setuptools-7.0\setuptools
\depends.py", line 6, in <module>
from setuptools import compat
File "c:\users\yc_00001\appdata\local\temp\tmpujxuqp\setuptools-7.0\setuptools
\compat.py", line 19, in <module>
from SimpleHTTPServer import SimpleHTTPRequestHandler
File "C:\Python27\lib\SimpleHTTPServer.py", line 27, in <module>
class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
File "C:\Python27\lib\SimpleHTTPServer.py", line 208, in SimpleHTTPRequestHand
ler
mimetypes.init() # try to read system mime.types
File "C:\Python27\lib\mimetypes.py", line 358, in init
db.read_windows_registry()
File "C:\Python27\lib\mimetypes.py", line 258, in read_windows_registry
for subkeyname in enum_types(hkcr):
File "C:\Python27\lib\mimetypes.py", line 249, in enum_types
ctype = ctype.encode(default_encoding) # omit in 3.x!
UnicodeDecodeError: 'ascii' codec can't decode byte 0xb0 in position 1: ordinal
not in range(128)
Something went wrong during the installation.
See the error message above.
-
解决方案,在网上找了很多方法,下面这个可用(忘了出处了,请原作者原谅....):
打开C:\Python27\Lib 找到mimetypes.py 在大概256行处找到default_encoding = sys.getdefaultencoding()
在这行前加上:
if sys.getdefaultencoding()!='gbk':
reload(sys)
sys.setdefaultencoding('gbk')
然后保存,再运行python ez_setup.py即可,下面是我自己的截图:
Python 安装setuptools报‘ascii’错误
最新推荐文章于 2021-02-09 15:05:05 发布
方法/步骤