python3.5 pip install markdown 时发生 "ValueError:the shebang (b'#!c:...)is not decode from utf8"
来源:互联网 发布:一亿玉碎 知乎 编辑:程序博客网 时间:2024/06/05 21:50
如上图。在网上找了好久,浏览了好多帖子,均得不到想要的结果。。都说文字编码引发的错误会把人逼疯,确实如此啊。
正当我快要放弃的时候,突然想我何不利用错误信息,自己尝试一下嘛。没想到这一下很快就解决了。下面是解决方法:
按照错误提示,我们打开这个文件:C:\Users\青霖\AppData\Local\Programs\Python\Python35\Lib\distutils\command\build_scripts.py,找到对应出错的语句块:
try: shebang.decode(encoding) except UnicodeDecodeError: raise ValueError( "The shebang ({!r}) is not decodable " "from the script encoding ({})" .format(shebang, encoding))
可以看到try语句块试图对一个字节流进行decode,失败时抛出错误,也就是我们看到的出错信息:shebang不能用utf8正确解码。
我尝试用gbk,甚至ascii进行decode。还是不成功,说明问题可能不在这里。我们接着往上看:
if not sysconfig.python_build: executable = self.executable else: executable = os.path.join( sysconfig.get_config_var("BINDIR"), "python%s%s" % (sysconfig.get_config_var("VERSION"), sysconfig.get_config_var("EXE"))) executable = os.fsencode(executable) shebang = b"#!" + executable + post_interp + b"\n"
注意到这段代码
os.fsencode()函数对地址executable进行encode。我们不知道这是utf-8还是什么别的格式,反正用decode(utf-8)竟然会出错!那我们不如干脆把它换成executable=executable.encode("utf-8")来试试:
executable = os.fsencode(executable)
os.fsencode()函数对地址executable进行encode。我们不知道这是utf-8还是什么别的格式,反正用decode(utf-8)竟然会出错!那我们不如干脆把它换成executable=executable.encode("utf-8")来试试:
哈哈,成功了!不试不知道,原来这么容易。。自己动手,丰衣足食!
希望能帮到你
阅读全文
0 0
- python3.5 pip install markdown 时发生 "ValueError:the shebang (b'#!c:...)is not decode from utf8"
- pip install :THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE
- pip install InsecurePlatformWarning: A true SSLContext object is not available.
- Python3.x 使用pip install pylint时报UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd5
- pip install 出现UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 73: ordinal not i
- The method * from the type * is not visible
- The method *** from the type *** is not visible
- pod install时出现错误"The dependency 'xxx' is not used in any concrete target"
- python3.5 pip安装
- pip install时发生raise ReadTimeoutError(self._pool, None, 'Read timed out.')的解决方案
- firebug 解决 "The resource from this URL is not text"
- tb_cat is not mapped [ select c from tb_cat c ]
- The _imaging C module is not installed
- The _imagingft C module is not installed
- The _imaging C module is not installed
- python2和python3同时存在时 pip install xxx 安装出错
- pip install operation not permitted 解决办法
- is not mapped [from
- Linux进程间通信
- IDEA----自动生成数据库实体类
- React全家同学习之ES6之字符串的扩展
- SIP初步
- 【头条】迈外迪新产品背后的商业逻辑
- python3.5 pip install markdown 时发生 "ValueError:the shebang (b'#!c:...)is not decode from utf8"
- Maven的聚合及继承
- 常用的分布式事务解决方案
- C++中const成员函数和非const成员函数的重载
- Python基础学习(2)
- Spring框架搭建
- 选择排序函数
- vue2.0之多页面的开发
- iOS WKWebView禁止长按事件(包括超链接)