• 0

ATOM - editor: how to set the paths - to Python


Question

hello dear  MX-experts

 

this is a question regarding the setup of a development-environment on a MX-Linux Machine, 

 

the questioin is: with the fresh  setup of ATOM - editor: how to set the paths - to Python

 

to begin with the beginning: 

 

i am pretty new to ATOM: first steps to configure to work with Python on MX-Linux

 

just have installed ATOM on the MX-Linux.

the question is: how to set the paths - to Python.
note: i allready have installed Python on my Mx-Machine.

Which packages do you suggest me to use … to run ATOM with Python!?

 

love to hear from you

 

Link to comment
Share on other sites

11 answers to this question

Recommended Posts

  • 0

hi there  I am back again 

 

 

well on my MX linux python is allready installed - so this is done by default. 

probably i need to set the paths"? 

 

 

i try to run a python code and then i see if it works 

 

 

- btw. how to get conda - i did not find it in the installer of ATOM!? 

i googled and found the following: 

https://anaconda.org/anaconda/atom
 
 Description
 Atom is a framework for creating memory efficient Python objects with enhanced features such as dynamic initialization, validation, and change notification for object attributes. 

well should i go this way: 


 To install this package with conda run:
 `conda install -c anaconda atom`

found at the above mentioned site,,,  https://anaconda.org/anaconda/atom

 

 

which things do you add to ATOM to run it as a python-coding editor... 

 

love to hear from you

Link to comment
Share on other sites

  • 0

dear Pythonists - dear experts here at NeoWin 

  

i am on MX-linux which is great. but there is no vscode (or even Codium) in the repos of MX-Linux. This is a question regarding the setup of a development-environment on a MX-Linux Machine,  unfortunatly there is no VSCode in the repos - so i need some alternatives: 

 

cf: https://forum.mxlinux.org/viewtopic.php?f=55&t=55936&p=565840#p565840

note: this is sad sad sad. We need to change this pretty soon. Do you have some ideas to get things done her.

 

regarding the actual situation:- on my actual machine.- i thought of using ATOM or PyCharme  i have some experience with both of them - but ATOM i used years ago. 

so here some question regarding the setup and the configuration - and adding packages:

 

the question is: with the fresh setup of ATOM - editor: how to set the paths - to Python to begin with the beginning:-which extensions and packages do you suggest for getting started. Can you suggest some of the most important..ones?

 

as mentioned above: i am (again) pretty new to ATOM: first steps to configure to work with Python on MX-Linux

just have installed ATOM on the MX-Linux.

 

additional: - the question is: how to set the paths - to Python.

note: i allready have installed Python on my Mx-Machine: there 3.7xy is installed. 

Which packages do you suggest me to use … to run ATOM with Python!?

 

look forward to hear from you

 

yours Tarifa

 

 

update:  now i encountered something new: Unable to start the Python language server ::  python -m pip install 'python-language-server[all]'

 

the question as of today: Unable to start the Python language server ::  python -m pip install 'python-language-server[all]'

 

added a pyhton code and suddenly i  got back the following waring 

 

    Unable to start the Python language server.

    Make sure to install pyls 0.19 or newer by running:

 

and the following one: 

 

    python -m pip install 'python-language-server[all]'

 

well  - to be frank ;: i am on MX-Linux and there Pyton is installed by default. So whats the fuss?!

 

 

i am not sure what ATOM wants from me now!?

 

can any body help out here

 

Link to comment
Share on other sites

  • 0
16 minutes ago, tarifa said:

 


    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]'

i am not sure what ATOM wants from me now!?

It's literally telling you in the error message the command you need to run!

Link to comment
Share on other sites

  • 0
16 hours ago, DaveLegg said:

It's literally telling you in the error message the command you need to run!

Hi there good  day dear DaveLegg, many thanks for the quick reply - i have used ATOM years ago - now in these  days (ih have lots of sparetime due to Corona-lockdown here) i have time to work with Atom again.  It is a headstart. 

 

At the moment i am allready running python-scripts. So some of the complaints i just dismiss. - since it works either.. 

regarding the above message : this message shows up while i add a new file to my development folder -/which does not reside in the ATOM-folder - what may be a problem. 

Well in other words i put the files into 

 

martin/dev/ python 

 

while the ATOM-Editor lies is 


 

ATOM 


Davelegg - is this possibly the issue where the complaines are rooted!? The different paths ...

 

Again - if i run the script with packages/script - then all goes well and i can see that all works propperly

 

sorry for being the novice - and for asking dump questions.

 

have a great day

Link to comment
Share on other sites

  • 0

ahh hi there DaveLegg just another question - this fits here very well - i guess that i do not need to open a new thread...

 

i have added Script-package -which works fine.

 

all is well now: one question:

 

running Python-Script: with script-pagage: where to see the output - where can i see the output of the script!?

i haver the screens divided and all i see is the following:

 

 

[Finished in 3.141s]

 

 

this is the script:

 

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"]')

 

see my screen ... how all is organized... - the question is:  how can i arrange the whole ATOM so that i can see 

 

a, the script 

b. the command-line and 

c. the output!?  .... which means - the output of the little bs4-script...

 

 

love to hear from you.. 

regards tarifa

 

 

image.thumb.png.310e2d36e76c815adffb3466cf2f62be.png

Link to comment
Share on other sites

  • 0

hello dear DaveLegg hello dear fellows, 

 

 

above all. well i hope you and your family is well - and all goes well in your location. How is your town dealing with covit19? I hope that we can overcome this crisis soon. 

 

ad i get continued messages and as i encounter issues day by day i just add the findings here - perhaps we can solve them in this thread.  many many thanks to you and for any and all help. 

 

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.

 

(#)[Popular Kernels](#)[All 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

 

Dave - 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 ... see the image: 

 

 image.thumb.png.5ec325b5ab931dfb061b0bba00284d87.png

 

look forward to hear from you 

 

regards

Link to comment
Share on other sites

  • 0

 

 

update: well - i guess that Hydrogen requires more than a plain Python interpreter. It provides functionality much like a Jupyter Notebook.

 

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

 

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

 

 

Link to comment
Share on other sites

  • 0

hi there - well i guess that there are still some packages missing on my machine. 

 

 

see the next trial

 

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]


 

   

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

 

i guess that there is something wrong

 

i have to digg deeper what goes on here. 

 

 

see the next trial

 

 

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 fellows  - i look forward to hear from you - i must figure out what goes on here.

 

Edited by tarifa
Link to comment
Share on other sites

  • 0

dear Davelegg dear fellows, 

 

 

first of all - i hope that you are all well and all goes okay 

 

since it seems to belong all to the same issue and the same thing i add this to this thread. 

 

 


the question today is: How can we install the Python package other than using pip?th

 

 

i run Python on MX-Linux  - there is

 

 

root@mx:/home/martin# python3 --V
unknown option --V
usage: python3 [option] ... [-c cmd | -m mod | file | -] [arg] ...
Try `python -h' for more information.
root@mx:/home/martin# python3 -V
Python 3.7.3
root@mx:/home/martin# pip install pandas
bash: pip: command not found.

 

i have no pip on the machine:  if i want to install pandas with the following command it does not work

 

pip install pandas

 

 

well i guess that i first of all need to instal pip

 

1) Find the package at PyPI - the Python Package Index .


2) Download the source code,
3) Read the INSTALL.txt or README.txt for clue on installation.
4) Usually installation is made of these steps
     $ python setup.py   build
     $ python setup.py  install

 

If you do not have EasyBuild installed yet, or if you just want to install the most recent version of each of the EasyBuild packages, you can use one of the following simple commands:

 

using easy_install (old tool, but still works):

 

easy_install --prefix $HOME/EasyBuild easybuild

 

Note If we already have easybuild installed, we may need to instruct easy_install to install a newer version, using --upgrade or -U.

 

using pip (more recent and better installation tool for Python software):

 

pip install --install-option "--prefix=$HOME/EasyBuild" easybuild

The --prefix $HOME/EasyBuild part in these commands allows you to install EasyBuild without admin rights into $HOME/EasyBuild.

 

 

Note For pip v8.0 and newer, pip install --prefix=$HOME/EasyBuild easybuild works too.

 

but wait: this page tells us that pip should be no my machine: 

pip is already installed if you are using Python 2 >=2.7.9 or Python 3 >=3.4 downloaded from python.org or if you are working in a Virtual Environment created by virtualenv or pyvenv. Just make sure to upgrade pip.

 

Installing with get-pip.py To install pip, securely   download get-pip.py by following this link: get-pip.py. Alternatively, use curl:

 

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

 

Then run the following command in the folder where you have downloaded get-pip.py:

 

python get-pip.py

Warning Be cautious if you are using a Python install that is managed by your operating system or another package manager. get-pip.py does not coordinate with those tools, and may leave your system in an inconsistent state.

 

so after all i am a bit confused: what  should i do - if i want to install pandas

- the questions are:

- wich options do i have to install pandas without pip 
- besides that: am i able to install pip with a simple method without running into any troubles?!?
- what should i do have to look for the preliminary steps!?
- are there any stepstones or pitfalls here !?

 

 

Dear Davelegg - sorry for adding this also to the thread - but i guess that this is quite helpful since it belongs to the same area of scope and interest. 


love to hear from you

 

 

regards 

Link to comment
Share on other sites

  • 0

hi there good day 

 

i gathered more insights:  note i run the following code on MX-Linux version 19.1 (where Python runs in Version 3.7.xy) with a fresh installation of ATOM - 


cf: https://stackoverflow.com/questions/60908216/how-to-handle-multiple-urls-in-beautifultsoup-and-convert-the-data-into-datafram


 

    import requests
    from bs4 import BeautifulSoup
    import pandas as pd


    def Main(urls):
        with requests.Session() as req:
            allin = []
            for url in urls:
                r = req.get(url)
                soup = BeautifulSoup(r.content, 'html.parser')
                target = soup.find(
                    "dl", class_="c-description-list c-description-list--striped")
                names = [item.text for item in target.findAll("dt")]
                names.append("url")
                data = [item.get_text(strip=True) for item in target.findAll("dd")]
                data.append(url)
                allin.append(data)
            df = pd.DataFrame(allin, columns=names)
            df.to_csv("data.csv", index=False, encoding="utf-8")


    urls = ['https://www2.daad.de/deutschland/studienangebote/international-programmes/en/detail/4722/',
            'https://www2.daad.de/deutschland/studienangebote/international-programmes/en/detail/6318/']
    Main(urls)

 


question - how to find out where the script stores the results - the csv-file. 

can i set the paths in ATOM some how some way - are there some options to do this!?


btw:  very interesting without the encoding = "utf-8" in the line   df.to_csv("data.csv", index=False, encoding="utf-8") i have errors since ihave UnicodeEncodeError, seems that my system default encoding isn't utf-8, therefor, 



guessing:  i guess that i set up the machine /ATOM badly … - any and all help greatly appreciated. - 

 

 

    Traceback (most recent call last):
      File "/home/martin/dev/python/daad_studienangebote_url_liste.py", line 25, in <module>
        Main(urls)
      File "/home/martin/dev/python/daad_studienangebote_url_liste.py", line 20, in Main
        df.to_csv("data.csv", index=False)
      File "/usr/local/lib/python2.7/dist-packages/pandas/core/generic.py", line 3020, in to_csv
        formatter.save()
      File "/usr/local/lib/python2.7/dist-packages/pandas/io/formats/csvs.py", line 172, in save
        self._save()
      File "/usr/local/lib/python2.7/dist-packages/pandas/io/formats/csvs.py", line 288, in _save
        self._save_chunk(start_i, end_i)
      File "/usr/local/lib/python2.7/dist-packages/pandas/io/formats/csvs.py", line 315, in _save_chunk
        self.cols, self.writer)
      File "pandas/_libs/writers.pyx", line 75, in pandas._libs.writers.write_csv_rows
    UnicodeEncodeError: 'ascii' codec can't encode character u'\xa0' in position 39: ordinal not in range(128)
    [Finished in 3.134s]

 

 

with the correct encoding the script runs very well python - daad_studienangebote_url_liste.py:21

 

i get back this result in the ATOM -.. 
 

`[Finished in 5.461s]`

 

but there remain two little questions: 

 

a. how ot set the default encoding in ATOM !? 
b. how - and where set the paths in ATOM !? 


love to hear from you 

Link to comment
Share on other sites

  • 0

Dear fellows,

 

Regarding the issues: 

 

a. how ot set the default encoding in ATOM !? 
b. how - and where set the paths in ATOM !? 

 

i will digg deeper into all that

 

 

for a. i guess that the solution will be this here - a solver for the default encoding.

atom-default-encoding package:

 

 

atom-default-encoding package

 

see the link: https://atom.io/packages/default-encoding

 

image.thumb.png.d1ed03f32606ad6da0aeb58b6f35740e.png

 

what it does: Specify default encodings in config for a specific scope selector. If no config default is found, try to autodetect encoding.

 

 

 

for b. regarding the setup of python in Atom - and for the question of where the system saves the data - i found out this - hope this may help others too:

 

 

 

above all  - stay healthy - and all the best to  you both!!! 

 

have a great day.

Edited by tarifa
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.