Script fails at import Gtk - gtk

I've spent some time looking into this and I can't seem to find anyone else with this issue which leads me to believe that I may just be stupid...
I have a few python scripts that attempt to use Gtk to create windows and they fail with the error message "Unable to init server: Could not connect: Connection refused". I've tracked this down to Gtk because I get the same error with the following script:
import gi
gi.require_version("Gtk","3.0")
from gi.repository import Gtk
Any and all help would be very much appreciated.

Related

Pydev showing 'undefined variable' for Jython code analysis

I have used Eclipse, Jython & Pydev for a long time. Upgrading as and when new releases arrived. All has worked very well until recently when the Pydev code completion started marking common items such as dir or print as 'undefined variable'. But the program ran correctly.
The error log showed:
'The python client still hasn't connected back to the eclipse java vm (will retry..)'
'Attempt: 2 of 5 failed, trying again...(socket connected still null)'
and more attempts to 5 out of 5
'Error connecting to python process(most likely cause for failure is firewall blocking...misconfigured network)'
Also, attempting to create a live jython console CTRL+ALT+ENTER gives the following error:
'Create interactive Console' has encountered a problem
Error initializing console.
Unexpected error connecting to console.
Failed to receive suitable Hello response from pydevconsole. Last msg received: Console already exited with value: 1 while waiting for an answer.
I have spent a lot of time looking for answers here and elsewhere that have included suggestions to check:
Mixed 32/64 bit installs; Firewall problems; IPV4 preference; localhost entries; path issues and others: all I've checked out with no success so far.
Software is Windows 10, Eclipse 4.21.0, Pydev 9.1.0.2021, Java JDK 11.0.13, Jython 2.7.2
I should be most grateful for any further help on this problem.
Many thanks
Well, you get that message because PyDev does spawn a shell and communicate with it for collecting code-completion results and the same happens for the interactive console.
Now, in both cases it seems like the socket communication is being prevented in your use case (as the messages states, the usual culprit is some firewall -- or possibly an anti-virus -- or some network misconfiguration).
Unfortunately, it's really hard for me to diagnose this as it's pretty much machine-dependent (all I can say is that I checked things here and Jython is working well, so, the issue lies in some misconfiguration on your machine).
I actually have plans to stop requiring that socket communication (for getting the completions from a shell) and using stdin/stdout (https://www.brainwy.com/tracker/PyDev/1183), but this still isn't done.
As Jython does run for you, you can try to create a simple server to verify a connection works.
i.e.: Create an echo_server.py with:
import socket
if __name__ == '__main__':
HOST = '127.0.0.1'
PORT = 65432
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((HOST, PORT))
s.listen(1)
conn, addr = s.accept()
print('Connected by', addr)
data = conn.recv(1024)
conn.sendall(data)
print('Echo server finished')
and a client.py with:
import socket
if __name__ == '__main__':
HOST = '127.0.0.1'
PORT = 65432
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))
s.sendall(b'Hello, world')
data = s.recv(1024)
print('Received %r' % (data,))
Then run the server part and then the client part and check if that does work properly for you.

VS code showing Error: Session cannot generate requests after every use of catboost with gpu

I have been trying to use my Nvidia Geforce GTX 1650 GPU for training catboost regressor.
It worked well but after finish training, it kills the kernel and needs to restart the vs code
Here is the code:-
import pandas as pd
import numpy as np
df = pd.read_csv('train.csv')
test = pd.read_csv('test.csv')
from catboost import CatBoostRegressor
cat = CatBoostRegressor(iterations=2000,learning_rate=0.061582,task_type='GPU')
cat.fit(df.drop('loss',axis = 1),df.loss)
This run fine but every time I try to run the next cell it shows this error:
Error: Session cannot generate requests
Error: Session cannot generate requests
at w.executeCodeCell (c:\Users\singh\.vscode\extensions\ms-toolsai.jupyter-2021.8.1236758218\out\client\extension.js:90:327199)
at w.execute (c:\Users\singh\.vscode\extensions\ms-toolsai.jupyter-2021.8.1236758218\out\client\extension.js:90:326520)
at w.start (c:\Users\singh\.vscode\extensions\ms-toolsai.jupyter-2021.8.1236758218\out\client\extension.js:90:322336)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async t.CellExecutionQueue.executeQueuedCells (c:\Users\singh\.vscode\extensions\ms-toolsai.jupyter-2021.8.1236758218\out\client\extension.js:90:336863)
at async t.CellExecutionQueue.start (c:\Users\singh\.vscode\extensions\ms-toolsai.jupyter-2021.8.1236758218\out\client\extension.js:90:336403)
I have updated all my packages using pip-review, updated jupyter extension, and xgboost with tree_method = 'gpu_hist' is working fine.
Operating System - Windows
Cuda version - 11.2
Nvidia Driver - 462
I had the same issue, I restarted the kernel and VS code and it seems to have fixed the issue.
In my experience, in only means that somewhere in my code there is an 'infinite loop'. The way I solved this was to restart VS Code and checked my code for said "infinite loop" before I rerun it again. I hope this helped...

Why am I getting a 500 response when using Deno and MongoDB?

I have the following code...
// test.mjs
import {MongoClient} from "https://dev.jspm.io/mongodb";
console.log("Loaded");
But when I run deno run ./test.mjs I get...
Download https://dev.jspm.io/npm:require_optional#1.0.1/index.dew.js
error: Import 'https://dev.jspm.io/npm:require_optional#1.0.1/index.dew.js' failed: 500 Internal Server Error
at https://dev.jspm.io/npm:require_optional#1?dew:1:0
What I am missing? I am using ChromeOs so basically Linux.

How to fix scrapy.utils.http deprecated warning

I am getting depreciation error while trying to scrapy deploy. Pretty new at this scraping.
deploy.py:23: ScrapyDeprecationWarning: Module scrapy.utils.http is deprecated, Please import from `w3lib.http nstead. from scrapy.utils.http import basic_auth_header
unknown target: local
Any help apreciated
feedback said "please import from w3lib.http.nstead", so i guess you need to modify the file "scrapyd-deploy"

How do I solve error "couldn't start tshark" in foren6

I'm trying to use foren6 tool in contiki OS. I'm trying to import a packet trace of a RPL collect network from foren6 examples guide.
While loading pcap files, I'm getting error "could not start tshark". How do I solve this error?
In foren6, file->Preference-> click "Old Tshark" ! and Start.......