我想在PyScripter的脚本中安装Python包。
import pip
package = 'xlsxwriter'
pip.main(['install', package])
发生以下错误:
Collecting xlsxwriter
Downloading XlsxWriter-0.9.3-py2.py3-none-any.whl (136kB)
Exception:
Traceback (most recent call last):
File "C:\Python27\ArcGIS10.4\lib\site-packages\pip\basecommand.py", line 215, in main
status = self.run(options, args)
File "C:\Python27\ArcGIS10.4\lib\site-packages\pip\commands\install.py", line 299, in run
requirement_set.prepare_files(finder)
File "C:\Python27\ArcGIS10.4\lib\site-packages\pip\req\req_set.py", line 370, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "C:\Python27\ArcGIS10.4\lib\site-packages\pip\req\req_set.py", line 587, in _prepare_file
session=self.session, hashes=hashes)
File "C:\Python27\ArcGIS10.4\lib\site-packages\pip\download.py", line 810, in unpack_url
hashes=hashes
File "C:\Python27\ArcGIS10.4\lib\site-packages\pip\download.py", line 649, in unpack_http_url
hashes)
File "C:\Python27\ArcGIS10.4\lib\site-packages\pip\download.py", line 871, in _download_http_url
_download_url(resp, link, content_file, hashes)
File "C:\Python27\ArcGIS10.4\lib\site-packages\pip\download.py", line 577, in _download_url
progress_indicator = DownloadProgressBar(max=total_length).iter
File "C:\Python27\ArcGIS10.4\lib\site-packages\pip\utils\ui.py", line 158, in __init__
super(WindowsMixin, self).__init__(*args, **kwargs)
File "C:\Python27\ArcGIS10.4\lib\site-packages\pip\utils\ui.py", line 82, in __init__
super(InterruptibleMixin, self).__init__(*args, **kwargs)
File "C:\Python27\ArcGIS10.4\lib\site-packages\pip\utils\ui.py", line 118, in __init__
super(DownloadProgressMixin, self).__init__(*args, **kwargs)
File "C:\Python27\ArcGIS10.4\lib\site-packages\pip\_vendor\progress\helpers.py", line 58, in __init__
if self.file.isatty() and self.hide_cursor:
File "<string>", line 523, in __getattr__
File "C:\Program Files (x86)\PyScripter\Lib\rpyc.zip\rpyc\core\netref.py", line 150, in __getattr__
return syncreq(self, consts.HANDLE_GETATTR, name)
File "C:\Program Files (x86)\PyScripter\Lib\rpyc.zip\rpyc\core\netref.py", line 71, in syncreq
return conn.sync_request(handler, oid, *args)
File "C:\Program Files (x86)\PyScripter\Lib\rpyc.zip\rpyc\core\protocol.py", line 434, in sync_request
raise obj
AttributeError: DebugOutput instance has no attribute 'isatty'
为什么会出现此错误以及如何修复错误?直接使用Python解释器时,相同的代码可以正常工作,但出于某种原因,不能使用PyScripter。
非常感谢你的帮助。