Error on websocket when try to use Ipython notebook in emacs - emacs

Got some error message in buffer Warning when try to evaluate my code
Error (websocket): in callback `on-open': Cannot send message to a closed websocket: cl-struct-websocket-frame, text, "{\"header\":{\"msg_id\":\"14735853-0ed2-4ef4-8f5a-312a198dd251\", \"username\":\"username\"\, \"session\":\"ab484abf-d4e6-4f83-2c2-de1b65264780\", \"msg_type\":\"execute_request\"}, \"metadata\":{}, \"content\":{\"code\":\"__import__('sys').stdout.write(__import__('os').getcwd())\", \"silent\":true, \\"user_variables\":[], \"user_expressions\":{}, \"allow_stdin\":false}, \"parent_header\":{}}", nil, t
Error (websocket): in callback `on-open': Wrong type argument: arrayp, nil
Error (websocket): in callback `on-close': Wrong type argument: arrayp, nil
And on the ipython server side I saw this message
2014-03-05 23:24:40.760 [NotebookApp] WARNING | Cross Origin WebSocket Attempt.
2014-03-05 23:24:40.761 [tornado.application] ERROR | Uncaught exception in /kernels/2691bbe3-ce95-439b-a9ce-97ec52c80988/shell
Traceback (most recent call last):
File "/home/haroldwu/Python-test/lib/python3.3/site-packages/tornado/websocket.py", line 322, in wrapper
return callback(*args, **kwargs)
File "/home/haroldwu/Python-test/lib/python3.3/site-packages/IPython/html/base/zmqhandlers.py", line 114, in open
raise web.HTTPError(404)
tornado.web.HTTPError: HTTP 404: Not Found
What I have done:
Upgrade all package of my python virtualenv and global environment
Upgrade all system package (Archlinux latest 64-bit)
Upgrade all emacs package
Search the web (but found no useful result)
Ipython notebook worked on my emacs weeks ago, but somehow it dosen't work now...
I have no experience on tornado.
Thanks for your help!!! :)

I'd guess that emacs is not sending the Origin header which is checked by the Notebook WS code. See my comment https://github.com/ipython/ipython/issues/5525 .
Quick workaround is to comment out the same origin check in your /home/haroldwu/Python-test/lib/python3.3/site-packages/IPython/html/base/zmqhandlers.py:114 .
You can always add logging of parsed_origin, origin and origin_header in same_origin() function in zmqhandlers.py and fix the emacs package accordingly.

Related

Scopus500Error: Error calling Solr Search Service

when I used pybliometrics to get the co_authors, sometimes I get this error, but sometimes not
I want to know why and how to solve it.
Traceback (most recent call last):
File "G:\dissertationdatabase\iteration3\iteration3.py", line 16, in <module>
coauthors = pd.DataFrame(au.get_coauthors())
File "C:\ProgramData\Miniconda3\lib\site-packages\pybliometrics\scopus\author_retrieval.py", line 289, in get_coauthors
res = get_content(url, api="AuthorSearch")
File "C:\ProgramData\Miniconda3\lib\site-packages\pybliometrics\scopus\utils\get_content.py", line 97, in get_content
raise errors[resp.status_code](reason)
Scopus500Error: Error calling Solr Search Service
Errors in the 5xx area are due to server errors. My feeling is that they're often idiosyncratic. Only Elsevier can tell what's really happening.
If this has worked previously, but is not working now, my suggestion would be to retry to see if this was a temporary issue.
If the problem persists, please contact Elsevier Support:
https://service.elsevier.com/app/contact/supporthub/researchproductsapis/

Eclipse / PyDev Stop button not working with OSError: [WinError 6] The handle is invalid error

I have the following Eclipse version on Windows 10:
Version: 2020-09 (4.17.0)
Build id: 20200910-1200
I am using PyDev along with it.
In my code I am using selenium to make a number of url calls (web scraping). When it happens that a particular url is not present or at least not present in the way most of the urls I am reading are, I get the following error:
Traceback (most recent call last):
File "C:\Users\foobar\eclipse-workspace\WeatherUndergroundUnderground\historical\BWI_Fetch.py", line 44, in <module>
main(city, month_date, start_year, end_year)
File "C:\Users\foobar\eclipse-workspace\WeatherUndergroundUnderground\historical\BWI_Fetch.py", line 22, in main
driver.get(city_url);
File "C:\Users\foobar\AppData\Local\Programs\Python\Python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 333, in get
self.execute(Command.GET, {'url': url})
File "C:\Users\foobar\AppData\Local\Programs\Python\Python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Users\foobar\AppData\Local\Programs\Python\Python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: Reached error page: about:neterror
Exception ignored in: <function Popen.__del__ at 0x0000019267429F70>
Traceback (most recent call last):
File "C:\Users\foobar\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 945, in __del__
self._internal_poll(_deadstate=_maxsize)
File "C:\Users\foobar\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 1344, in _internal_poll
if _WaitForSingleObject(self._handle, 0) == _WAIT_OBJECT_0:
OSError: [WinError 6] The handle is invalid
When I get this particular error, eclipse is still running and pushing the red stop button does not work to end the program. I can usually use the red stop button for just about any other python program I have written, but this code/error seems to hang things. How can I end the process from within the Eclipse application?
The error in the stack trace is not really related to PyDev, so, the stack trace error is only really fixable in Selenium/Python (the error says that it's trying to access a process which is already dead on the __del__).
Now, related to the reason why PyDev wasn't able to kill it, I think that you probably have some process which spawned a subprocess and is not reachable anymore because the parent process died and thus it's not possible to create a tree to kill that process from the initial process launched in PyDev.
The actual code which does this in PyDev is: https://github.com/fabioz/winp/blob/master/native/winp.cpp#L208
I think that it should be possible to use the windows api to create a JobObject and then AssignProcessToJobObject and on kill also kill the JobObject so that it kills all associated processes so that things are setup in a way that that this doesn't happen, but this isn't currently done.
As a note, usually I have an alias for: taskkill /im python.exe /f (which will kill all the python.exe processes running in the machine) and it's what I usually use in such cases, so, if something like that happens I just kill all the python.exe processes in the machine.
Although note that if you spawned some other process... say, chrome.exe -- in that process tree, that process must also be killed for the initial shell that launched python to be really disposed.
This error message...
Exception ignored in: <function Popen.__del__ at 0x0000019267429F70>
...implies that the builtins module was destroyed before running __del__ in process of garbage collecting.
Hence PyDev is no more able to communicate with the relevant python modules. As a result Stop button isn't functioning and raises the error:
OSError: [WinError 6] The handle is invalid

Importing python modules using sublime text3

I'm learning Python 3.7, and Sublime Text3. Most programs run fine using control + b, but when I try to import a module from the standard library like random, I get the following error(Please note that I am not running the program from OneDrive, but from my own computer!)
Traceback (most recent call last):
File "C:\Users\chris\OneDrive\Documents\Python Programs\guess.py", line 1, in <module>
import random
File "C:\Users\chris\OneDrive\Documents\Python Programs\random.py", line 1
>>> import os
^
SyntaxError: invalid syntax
Obviously the OneDrive thing is a problem ,but what can I do?
Many thanks.
The part of the error message that you want to focus on here is the last part of the stack trace, which is showing you the line that has the problem and where the problem is, i.e.:
>>> import os
^
SyntaxError: invalid syntax
Based on this, your input file has the characters >>> in front of the import statement which, as the message indicates, is not valid Python syntax. Removing those characters should solve the problem for you. The line immediately above the error is showing you the name of the file that has the problem (in this case random.py).
The >>> is the prompt that the interactive Python interpreter gives you when you run it, as it's prompting you for what text to enter. That's not something that should appear in your code at all.
Check the random.py file, as the error message states, it's a syntax error due to the the >>> repl symbol in there.

Enthought Canopy - "IOError: [Errno 10038]" when install or update packages in Package Manager

I have installed Canopy 1.7.4.3348 (64 bit). My OS is Windows 10 (64 bit). I have the most updated Canopy and Windows 10.
When I tried to update and install any packages in Package Manager, the "Status" would turn out to be "Error", and I got the message:
IOError: [Errno 10038] An operation was attempted on something that is not a socket.
I looked up the Error code on microsoft.com (https://msdn.microsoft.com/en-us/library/windows/desktop/ms740668(v=vs.85).aspx) and found Microsoft's definition of socket error 10038:
WSAENOTSOCK 10038
Socket operation on nonsocket.
An operation was attempted on something that is not a socket.
Either the socket handle parameter did not reference a valid socket,
or for select, a member of an fd_set was not valid.
I think this error from Canopy may only exist in Windows but not in other OS like Linux. Could anyone please kindly help with this issue? Really appreciate it!!
The detailed messages are as below:
Warming up...
Traceback (most recent call last):
File "build\bdist.win-amd64\egg\canopy_dashboard\packman\package_action_worker.py", line 54, in run
File "build\bdist.win-amd64\egg\canopy_dashboard\packman\package_action.py", line 193, in execute
File "build\bdist.win-amd64\egg\canopy_dashboard\packman\packman.py", line 346, in <lambda>
File "build\bdist.win-amd64\egg\canopy_dashboard\packman\packman.py", line 893, in _install
File "build\bdist.win-amd64\egg\canopy_platform\cpython_packages_manager.py", line 98, in install_package
File "build\bdist.win-amd64\egg\canopy_platform\enpkg_api.py", line 102, in install_package
File "build\bdist.win-amd64\egg\canopy_platform\enpkg_api.py", line 177, in _execute_in_subprocess
File "build\bdist.win-amd64\egg\canopy_platform\enpkg_api.py", line 212, in _propagate_progress_events
IOError: [Errno 10038] An operation was attempted on something that is not a socket
Please file a bug report from the Canopy help menu for Enthought tech support records (and please refer to this SO question in your report).
I don't know what causes this rare error, but it should disappear in Canopy 2.0, which uses a different package manager backend, based on the Enthought Deployment Manager (EDM).
Meanwhile, you can avoid the error by using the command-line package installer, enpkg, from a Canopy Command Prompt. Please see this Knowledge Base article for details: https://support.enthought.com/entries/22415022-Using-enpkg-to-update-Canopy-EPD-packages.

IOError error message in IPython notebook when using StarCluster

I am running a small StarCluster and using it to run an IPython Notebook. Every time I have an error in the code I'm writing in the notebook, I get the following error message added onto the end of the notebook's output:
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 872, in emit
stream.write(fs % msg)
IOError: [Errno 32] Broken pipe
Logged from file ipkernel.py, line 427
Other than that, it seems to be running OK, but I don't know why that might be happening / how I can find out more about why it's doing that