IPython NoConsoleScreenBufferError (Windows) - python

When running any line on the IPython CLI on Windows, most times I am getting a NoConsoleScreenBufferError and the console is terminated.
This happens when running IPython from the Windows terminal (cmd.exe > ipython) or when using the embedded PyCharm terminal (it uses the Windows terminal) which chooses IPython automatically over the regular Python terminal, in installed.
Here is part of the relevant trace:
File "C:\Python27\lib\site-packages\IPython\__init__.py", line 119, in start_ipython
return launch_new_instance(argv=argv, **kwargs)
File "C:\Python27\lib\site-packages\traitlets\config\application.py", line 658, in launch_instance
app.start()
File "C:\Python27\lib\site-packages\IPython\terminal\ipapp.py", line 348, in start
self.shell.mainloop()
File "C:\Python27\lib\site-packages\IPython\terminal\interactiveshell.py", line 486, in mainloop
self.interact()
File "C:\Python27\lib\site-packages\IPython\terminal\interactiveshell.py", line 469, in interact
code = self.prompt_for_code()
File "C:\Python27\lib\site-packages\IPython\terminal\interactiveshell.py", line 363, in prompt_for_code
pre_run=self.pre_prompt, reset_current_buffer=True)
File "C:\Python27\lib\site-packages\prompt_toolkit\interface.py", line 392, in run
self._redraw()
File "C:\Python27\lib\site-packages\prompt_toolkit\interface.py", line 351, in _redraw
self.renderer.render(self, self.layout, is_done=self.is_done)
File "C:\Python27\lib\site-packages\prompt_toolkit\renderer.py", line 398, in render
size = output.get_size()
File "C:\Python27\lib\site-packages\prompt_toolkit\terminal\win32_output.py", line 103, in get_size
info = self.get_win32_screen_buffer_info()
File "C:\Python27\lib\site-packages\prompt_toolkit\terminal\win32_output.py", line 150, in get_win32_screen_buffer_info
raise NoConsoleScreenBufferError
NoConsoleScreenBufferError: No Windows console found. Are you running cmd.exe?
If you suspect this is an IPython bug, please report it at:
https://github.com/ipython/ipython/issues
or send an email to the mailing list at ipython-dev#scipy.org
You can print a more detailed traceback right now with "%tb", or use "%debug"
to interactively debug it.
Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
%config Application.verbose_crash=True

Related

I get a traceback error when using the command "pipenv run python"

UPDATE: The issue comes from the special characters in the path where the .virtualenv directory is created. I fixed it by rerouting the .virtualenv in C: and will eventually edit the username to avoid this issue in the future.
I am having some trouble with "pipenv run" on my work laptop (windows pro) and can't seem to find an explanation to my issue. For example, I create a test directory on the desktop in which I put a basic scripts that prints "Hello".
I initiate pipenv in the project folder and it works fine, I can fire up the shell, install packages, run the script (While in the shell), etc..
However, I get a traceback whenever I try to run the script from the main command prompt as such (not inside of pipenv shell):
C:\Users\jérôme\Desktop\tester> pipenv run python testit.py
some other details:
running the above command on my personal machine (windows family edition) works fine
I did "pipenv lock" before to check if it could be the issue. It was not
I am using python 3.7.9 on both machine
Python was added to path variables on installation
I tried with python 3.8.6 as well and get the same error
I tried uninstalling completely all python versions and reinstalling it
the username on my work machine as special characters (é, ô) could it be the reason?
Traceback Error...
Traceback (most recent call last):
File "c:\users\jérôme\python37\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\users\jérôme\python37\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\jérôme\Python37\Scripts\pipenv.exe\__main__.py", line 7, in <module>
File "c:\users\jérôme\python37\lib\site-packages\pipenv\vendor\click\core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "c:\users\jérôme\python37\lib\site-packages\pipenv\vendor\click\core.py", line 782, in main
rv = self.invoke(ctx)
File "c:\users\jérôme\python37\lib\site-packages\pipenv\vendor\click\core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "c:\users\jérôme\python37\lib\site-packages\pipenv\vendor\click\core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "c:\users\jérôme\python37\lib\site-packages\pipenv\vendor\click\core.py", line 610, in invoke
return callback(*args, **kwargs)
File "c:\users\jérôme\python37\lib\site-packages\pipenv\vendor\click\decorators.py", line 73, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "c:\users\jérôme\python37\lib\site-packages\pipenv\vendor\click\core.py", line 610, in invoke
return callback(*args, **kwargs)
File "c:\users\jérôme\python37\lib\site-packages\pipenv\cli\command.py", line 450, in run
command=command, args=args, three=state.three, python=state.python, pypi_mirror=state.pypi_mirror
File "c:\users\jérôme\python37\lib\site-packages\pipenv\core.py", line 2547, in do_run
run_fn(*run_args, **run_kwargs)
File "c:\users\jérôme\python37\lib\site-packages\pipenv\core.py", line 2468, in do_run_nt
p = _launch_windows_subprocess(script)
File "c:\users\jérôme\python37\lib\site-packages\pipenv\core.py", line 2458, in _launch_windows_subprocess
return subprocess.Popen([command] + script.args, **options)
File "c:\users\jérôme\python37\lib\subprocess.py", line 800, in __init__
restore_signals, start_new_session)
File "c:\users\jérôme\python37\lib\subprocess.py", line 1207, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
The root cause of the problem are the special characters in the user's directory path, where the pipenv's .virtualenv directory is also created by default. The OP reports to have fixed the problem by rerouting the .virtualenv in C: 
A quick test in, e.g. c:\tmp can help to rule out this cause.
I had this issue, I solved it by uninstalling anaconda.

Installing Google Cloud SDK throwing error in install.py when using install.bat

I am trying to install google cloud SDK using install.bat. I have tried downloading the bundled pythons versions 275 and current version 276, they both fail at the same spot. It is able to find python in the platform/bundledpython folder so that is not the issue. I have also tried the suggestions online including making sure that the "Find" command works on a command prompt. Any help appreciated.
The latest available version is: 276.0.0
���───────────────────────────────────────────────────────────────────────────────────────────────────────────────┐Trac
back (most recent call last):
File "C:\google-cloud-sdk\google-cloud-sdk\\bin\bootstrapping\install.py", line 225, in <module>
main()
File "C:\google-cloud-sdk\google-cloud-sdk\\bin\bootstrapping\install.py", line 203, in main
Install(pargs.override_components, pargs.additional_components)
File "C:\google-cloud-sdk\google-cloud-sdk\\bin\bootstrapping\install.py", line 148, in Install
_CLI.Execute(['--quiet', 'components', 'list'])
File "C:\google-cloud-sdk\google-cloud-sdk\lib\googlecloudsdk\calliope\cli.py", line 1007, in Execute
self._HandleAllErrors(exc, command_path_string, specified_arg_names)
File "C:\google-cloud-sdk\google-cloud-sdk\lib\googlecloudsdk\calliope\cli.py", line 1040, in _HandleAllErrors
exceptions.HandleError(exc, command_path_string, self.__known_error_handler)
File "C:\google-cloud-sdk\google-cloud-sdk\lib\googlecloudsdk\calliope\exceptions.py", line 527, in HandleError
core_exceptions.reraise(exc)
File "C:\google-cloud-sdk\google-cloud-sdk\lib\googlecloudsdk\core\exceptions.py", line 146, in reraise
six.reraise(type(exc_value), exc_value, tb)
File "C:\google-cloud-sdk\google-cloud-sdk\lib\googlecloudsdk\calliope\cli.py", line 981, in Execute
resources = calliope_command.Run(cli=self, args=args)
File "C:\google-cloud-sdk\google-cloud-sdk\lib\googlecloudsdk\calliope\backend.py", line 809, in Run
display_info=self.ai.display_info).Display()
File "C:\google-cloud-sdk\google-cloud-sdk\lib\googlecloudsdk\calliope\display.py", line 483, in Display
self._printer.Print(self._resources)
File "C:\google-cloud-sdk\google-cloud-sdk\lib\googlecloudsdk\core\resource\resource_printer_base.py", line 279, in P
int
self.Finish()
File "C:\google-cloud-sdk\google-cloud-sdk\lib\googlecloudsdk\core\resource\table_printer.py", line 467, in Finish
self._out.write(line)
File "C:\google-cloud-sdk\google-cloud-sdk\lib\googlecloudsdk\core\log.py", line 239, in write
self._Write(plain_text, styled_text)
File "C:\google-cloud-sdk\google-cloud-sdk\lib\googlecloudsdk\core\log.py", line 232, in _Write
self.__stream_wrapper.stream.write(stream_msg)
I just had the same problem trying to install the latest Google Cloud SDK (276.0.0). The Windows setup was stuck on "Installing components".
Looking at the process list with Process Explorer I could see it was running this command that was stuck, as you probably did to get your stack trace. I took the command line and ran it in a separate Administror cmd.exe (paths might differ per system, the idea is the same).
cd "C:\Program Files (x86)\Google\Cloud SDK"
SET "CLOUDSDK_CORE_DISABLE_PROMPTS=1"
SET "CLOUDSDK_CONFIG=%APPDATA%\gcloud"
"C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\install.bat" --quiet --disable-installation-options --path-update "FALSE" --usage-reporting "true" --additional-components beta powershell"
Running them would produce the same error / stack trace.
Editing log.py and commenting out (prefix with #) line 232 would make it get further, but it runs into a separate problem:
ERROR: Cannot use bundled Python installation to update Cloud SDK in non-interactive mode.
Please run again in interactive mode.
Enable prompts with CLOUDSDK_CORE_DISABLE_PROMPTS envvar and remove --quiet and --disable-installation-options from the install.bat command line and run it again.
SET "CLOUDSDK_CORE_DISABLE_PROMPTS=0"
"C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\install.bat" --path-update "FALSE" --usage-reporting "true" --additional-components beta powershell"
This time it should continue, start a new console where it actually installs the components and eventually finish succesfully.

django and python manage.py runserver execution error

When I execute python manage.py runserver command for my django_test projects I get following error:
System check identified no issues (0 silenced).
June 14, 2015 - 20:43:03
Django version 1.8.2, using settings 'django_test.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 390, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 49, in execute
super(Command, self).execute(*args, **options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 441, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 88, in handle
self.run(**options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 97, in run
autoreload.main(self.inner_run, None, options)
File "/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py", line 323, in main
reloader(wrapped_main_func, args, kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py", line 289, in python_reloader
reloader_thread()
File "/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py", line 265, in reloader_thread
change = fn()
File "/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py", line 190, in inotify_code_changed
update_watch()
File "/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py", line 184, in update_watch
wm.add_watch(path, mask)
File "/usr/lib/python2.7/dist-packages/pyinotify.py", line 1903, in add_watch
exclude_filter)
File "/usr/lib/python2.7/dist-packages/pyinotify.py", line 1822, in __add_watch
wd = self._inotify_wrapper.inotify_add_watch(self._fd, path, mask)
File "/usr/lib/python2.7/dist-packages/pyinotify.py", line 150, in inotify_add_watch
return self._inotify_add_watch(fd, pathname, mask)
File "/usr/lib/python2.7/dist-packages/pyinotify.py", line 245, in _inotify_add_watch
return self._libc.inotify_add_watch(fd, pathname, mask)
ctypes.ArgumentError: argument 2: <type 'exceptions.TypeError'>: expected CString instance instead of c_char_Array_64
I have never had this problem before and my code always worked fine until I moved the project from one laptop to the other and can not execute it here.
Originaly, it worked fine but the system crashed and it is first time when I am trying to run the code on the new machine. I use virtualenv so I would expect everything to work smoothly but it does not ...
Is it a problem with python itself ?
It looks like you're running against the system version of python on the new laptop, rather than the virtualenv, so it is probably a different version. You can check this by looking at the version of Python on the virtualenv in the old laptop and the new laptop with python --version - I've seen this error happen in this case to people before.
Your best bet is to create a new virtualenv on the new laptop, and reinstall your packages (hopefully, you have a requirements.txt handy). If you need the same version of Python on the new laptop, you'll have to explore getting that version installed on your new laptop (do not overwrite the system version!), and pointing your virtualenv to the install. Good luck.

Marmalade deploy - deployment.py, line 62, in SetOpt

I got a mac book pro retina and I'am trying to create a project from the .mkb file: but I got this error
Building project: /Users/sergioandreotti/Downloads/twins/template/marmalade/FeedtheTwins.mkb
Traceback (most recent call last):
File "/Developer/Marmalade/6.1/s3e/makefile_builder/mkb.py", line 209, in <module>
run()
File "/Developer/Marmalade/6.1/s3e/makefile_builder/mkb.py", line 137, in run
main(sys.argv)
File "/Developer/Marmalade/6.1/s3e/makefile_builder/mkb.py", line 32, in main
exit_code = mkb_main.run(argv)
File "/p4/sdkbuild/sdk/main/s3e/makefile_builder/mkb_main.py", line 3461, in run
File "/p4/sdkbuild/sdk/main/s3e/makefile_builder/mkb_main.py", line 3619, in run2
File "/p4/sdkbuild/sdk/main/s3e/makefile_builder/mkb_main.py", line 2697, in process_mkb_for_platform
File "/p4/sdkbuild/sdk/main/s3e/makefile_builder/mkb_main.py", line 690, in process
File "/p4/sdkbuild/sdk/main/s3e/makefile_builder/mkb_main.py", line 2602, in process_file
File "/p4/sdkbuild/sdk/main/s3e/makefile_builder/mkb_main.py", line 2124, in process
File "/p4/sdkbuild/sdk/main/s3e/makefile_builder/mkb_main.py", line 2124, in <lambda>
File "/p4/sdkbuild/sdk/main/s3e/makefile_builder/mkb_main.py", line 1971, in process
File "/p4/sdkbuild/sdk/main/s3e/makefile_builder/mkb_main.py", line 1130, in process_deployment_line
File "/p4/sdkbuild/sdk/main/s3e/makefile_builder/deployment.py", line 62, in SetOpt
NameError: global name 'output' is not defined
Press enter to continue...
I ve found this solution: https://devnet.madewithmarmalade.com/questions/2784/mkb-fails-to-build.html
but I don't think it's the best solution.
it's working for building the project but I got other problems when I have to deploy with the Marmalade deploy tool.
Sometimes deploy fails and the error in the error log is the same "global name 'output' is not defined"
I m not able to save my configuration in the .mkb, because if I do this, next time I reload the configuration, the deploy fails.
it was my fault, I had marmalade 6.1.1 installed instead of 6.1.2.
6.1.1 doensn't provide retina support and in the .mkb there was the tag "Enable 4-inch Retina Support" set.

Trying to Run Google App Engine behind a proxy, errors received

I am running Python 2.6.1 on my computer, and just installed google App Engine.
As soon as I click on the App Engine Launcher, it gives an error dialog box and asks me to check the GoogleAppEngineLauncher.exe file for more details.
I have appended the log file below:
File "GoogleAppEngineLauncher.py", line 42, in <module>
File "wx\_core.pyc", line 7913, in __init__
File "wx\_core.pyc", line 7487, in _BootstrapApp
File "launcher\app.pyc", line 58, in OnInit
File "launcher\app.pyc", line 152, in _VersionCheck
File "urllib.pyc", line 82, in urlopen
File "urllib.pyc", line 190, in open
File "urllib.pyc", line 338, in open_http
File "urllib.pyc", line 351, in http_error
File "urllib.pyc", line 702, in http_error_407
File "urllib.pyc", line 714, in retry_proxy_http_basic_auth
File "urllib.pyc", line 773, in get_user_passwd
File "urllib.pyc", line 782, in prompt_user_passwd
EOFError: EOF when reading a line
From the file, I get the feeling that it's about giving the right proxy details.
I have checked up http://code.google.com/p/google-appengine-wx-launcher/issues/detail?id=17
and http://code.google.com/p/googleappengine/issues/detail?id=544.
It seems that it is about making some edits to some particular .py file so that I can enter my proxy settings, and username/password.
I have also come across few suggestions telling me to set the proxy in environment variables at the command prompt - but that hasn't worked. Any suggestions, please?
UPDATE:
I came across the following at nomagon dot com /?p=5 I am using it but unable to make sense out of the appcfg.py file
If your're not behind a proxy, then your ok to go! You can use the deploy button inside the App Engine Launcher, however if you're behind a proxy, you will need to set some variables
In a CMD window:
set HTTP_PROXY=<proxy>
set HTTPS_PROXY=<prox>
In a CMD window:
appcfg.py update <path to app>

Categories