No kernel for grammar Python found - pykernel necessary - honestly?

hello dear fellows,

the topic of today: no kernel for grammar Python found - pykernel necessary - honestly?

well this is pretty confusing - i can run scripts - even in python.

but after installing hydrogen ( cf https://atom.io/packages/hydrogen ) i have encountered funny and very confusing things.

i want to run a little python script - and while doing a test with hydrogen>run i get back the following message:

see:

No Kernels Installed
No kernels are installed on your system so you will not be able to execute code in any language.

Install InstructionsPopular KernelsAll Kernels

No kernel for grammar Python found

Check that the language for this file is set in Atom, that you have a Jupyter kernel installed for it, and that you have configured the language mapping in Hydrogen preferences.

To detect your current Python install you will need to run:

python -m pip install ipykernel
python -m ipykernel install --user

well - what is pretty confusing - is the fact that i can run scripts - also python scripts - with the package called script: they work pretty well …

what goes on here - i have no glue

Hydrogen requires more than a plain Python interpreter. It provides functionality much like a Jupyter Notebook.

If all you want to do is run a small script, then I would just stick to the script package, or run it in a terminal.

1 Like

hi there Aerijo - many many thanks for the quick reply - i am very glad to hear from you

great - hydrogen is very very powerful - i like it.

but i want to see the output of the script - this is pretty important to me.

see the mentionied bs4 script…

see the both scripts - i want to see the output of the scirpt: how is this possible!?

from bs4 import BeautifulSoup
import requests

url = 'https://europa.eu/youth/volunteering/organisation/50164'
resonse = requests.get(url)
soup = BeautifulSoup(resonse.content, 'lxml')
tag_info = soup.select('.col-md-12 > p:nth-child(3) > i:nth-child(1)')
print(tag_info[0].text)

<<<<<<<<<<<<<<<<<<<<<<<

from bs4 import BeautifulSoup
import urllib

url = urllib.urlopen('http://meinparlament.diepresse.com/')
content = url.read()
soup = BeautifulSoup(content, 'lxml')

table = soup.findAll('div',attrs={"class":"content-question"})
for x in table:
    print x.find('p').text

# Another way to retrieve tables:
# table = soup.select('div[class="content-question"]')

love to hear from you

regards

The script package will print the output of the script (anything printed by print). Hydrogen will add a little box with the value of the variable / result of expression, etc., on each line in the editor itself.

1 Like

hi there dear Aerjo,

many ,many thanks for all your help i appreciate all your ideas and your support. i did some more tests and i encontered interesting results

to test the ATOM-Settings i did a testrun of several scripts that i found on the stackoverflow-page: see the following trials and the results: i am musing what goes wrong here - weather i have i not a complete installation of Python or a well configured ATOM editor. Any ideas here - i would be very happy.

see the following two examples:

from bs4 import BeautifulSoup
URL = "https://www.worldometers.info/coronavirus/"
r = requests.get(URL)
soup = BeautifulSoup(r.content, 'html5lib')
countHTML = soup.find('div', attrs = {'class':'content-inner'})

for countVar in countHTML.findAll('div', attrs = {'class':'maincounter-number'}):
    count = countVar.span



- i get back the following result: ` Traceback (most recent call last): File "/tmp/atom_script_tempfiles/0c9e3b30-6d27-11ea-84a4-095d4171334a", line 2, in <module> worldometers.info NameError: name 'worldometers' is not defined [Finished in 0.069s]` 

welll i am on MX-Linux on Atom and i do not know why i get this back!?`

see the second example: https://stackoverflow.com/questions/60780430/python-extract-3-integers-from-string

import csv
import requests
from bs4 import BeautifulSoup

URL = "https://www.passiton.com/inspirational-quotes?page={}"

quotes = []
page = 1

while True:
    r = requests.get(URL.format(page))
    print(r.url)
    soup = BeautifulSoup(r.content, 'html5lib')

    if not soup.select_one("#all_quotes .text-center > a"):break
    for row in soup.select("#all_quotes .text-center"):
        quote = {}
        try:
            quote['quote'] = row.select_one('a img.shadow').get("alt")
        except AttributeError: quote['quote'] = ""
        try:
            quote['url'] = row.select_one('a').get('href')
        except AttributeError: quote['url'] = ""
        try:
            quote['img'] = row.select_one('a img.shadow').get('src')
        except AttributeError: quote['img'] = ""
        quotes.append(quote)

    page+=1

i runned this and i got back the following result:

´https://www.passiton.com/inspirational-quotes?page=1
https://www.passiton.com/inspirational-quotes?page=2..
https://www.passiton.com/inspirational-quotes?page=n..
https://www.passiton.com/inspirational-quotes?page=44´

and besides that ´

Traceback (most recent call last):
  File "/home/martin/.atom/python/examples/bs_values_com.py", line 31, in <module>
    with open('inspirational_quotes.csv', 'w', newline="", encoding="utf-8") as f:
TypeError: file() takes at most 3 arguments (4 given)
[Finished in 55.861s]

cf https://stackoverflow.com/questions/60796795/web-scraping-in-python-with-beautifulsoup

i am just musing how and why i receive this. i am trying to figure it out.
any help greatly appreciated. greetings

Dear Aerijo - i look forward to hear from you - i must figure out what goes on here.

on a sidenote: each time i start the ATOM i get the following message …

Unable to start the Python language server. Make sure to install pyls 0.19 or newer by running: python -m pip install 'python-language-server[all]'

probably this message is the cause that i run into the various issues and troubles with running code-snippets

The language server error is related to how you probably have ide-python installed. This package will interface with a Python language server to provide linting, autocomplete, etc., but again needs a specific program installed (pyls), not just a Python interpreter.

For your Python errors, I don’t know. What you should do is run it in the command line directly. This will tell you if the error is related to running it with an Atom package (if it works on the command line directly), or with your program (if it still doesn’t work).

Also,

File “/home/martin/.atom/python/examples/bs_values_com.py”

Don’t store anything inside the .atom folder. This folder can and will delete it’s contents as it likes. Advice for fixing broken Atom installations can include deleting this folder. The same applies to storing work in any automatically created program folder. The safest thing to do is make a folder such as ~/python-projects and store your projects in there.

1 Like