running into issues while installing beautiful soup version 4 via terninal

hello dear Community

running into issues while installing beautiful soup version 4 via terninal on a leap 42.3





martin@linux-3645:~> pip install beautifulsoup4
Collecting beautifulsoup4
  Downloading beautifulsoup4-4.6.0-py3-none-any.whl (86kB)
    100% |████████████████████████████████| 90kB 405kB/s 
Installing collected packages: beautifulsoup4
Exception:
Traceback (most recent call last):
  File "/usr/lib/python3.4/site-packages/pip/basecommand.py", line 211, in main
    status = self.run(options, args)
  File "/usr/lib/python3.4/site-packages/pip/commands/install.py", line 311, in run
    root=options.root_path,
  File "/usr/lib/python3.4/site-packages/pip/req/req_set.py", line 646, in install
    **kwargs
  File "/usr/lib/python3.4/site-packages/pip/req/req_install.py", line 803, in install
    self.move_wheel_files(self.source_dir, root=root)
  File "/usr/lib/python3.4/site-packages/pip/req/req_install.py", line 998, in move_wheel_files
    isolated=self.isolated,
  File "/usr/lib/python3.4/site-packages/pip/wheel.py", line 339, in move_wheel_files
    clobber(source, lib_dir, True)
  File "/usr/lib/python3.4/site-packages/pip/wheel.py", line 310, in clobber
    ensure_dir(destdir)
  File "/usr/lib/python3.4/site-packages/pip/utils/__init__.py", line 71, in ensure_dir
    os.makedirs(path)
  File "/usr/lib64/python3.4/os.py", line 237, in makedirs
    mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/usr/lib/python3.4/site-packages/bs4'
You are using pip version 7.1.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
martin@linux-3645:~> 
                                                                         

what would you do ?

by the way - see the arrangement of the notebook - especially the hard drive



martin@linux-3645:~> zypper lr -uP
#  | Alias                     | Name                                    | Aktiviert | GPG-Überprüfung | Aktualisierung | Priorität | URI                                                                       
---+---------------------------+-----------------------------------------+-----------+-----------------+----------------+-----------+---------------------------------------------------------------------------
 1 | ecsos                     | ecsos                                   | Ja        | (r ) Ja         | Ja             |   99      | https://download.opensuse.org/repositories/home:/ecsos/openSUSE_Leap_42.3/
 2 | openSUSE-Leap-42.3-0      | openSUSE-Leap-42.3-0                    | Ja        | (r ) Ja         | Nein           |   99      | cd:///?devices=/dev/disk/by-id/ata-hp_DVDRAM_GU90N_KMNZ8C81556            
 3 | repo-debug                | openSUSE-Leap-42.3-Debug                | Nein      | ----            | ----           |   99      | http://download.opensuse.org/debug/distribution/leap/42.3/repo/oss/       
 4 | repo-debug-non-oss        | openSUSE-Leap-42.3-Debug-Non-Oss        | Nein      | ----            | ----           |   99      | http://download.opensuse.org/debug/distribution/leap/42.3/repo/non-oss/   
 5 | repo-debug-update         | openSUSE-Leap-42.3-Update-Debug         | Nein      | ----            | ----           |   99      | http://download.opensuse.org/debug/update/leap/42.3/oss/                  
 6 | repo-debug-update-non-oss | openSUSE-Leap-42.3-Update-Debug-Non-Oss | Nein      | ----            | ----           |   99      | http://download.opensuse.org/debug/update/leap/42.3/non-oss/              
 7 | repo-non-oss              | openSUSE-Leap-42.3-Non-Oss              | Ja        | (r ) Ja         | Ja             |   99      | http://download.opensuse.org/distribution/leap/42.3/repo/non-oss/         
 8 | repo-oss                  | openSUSE-Leap-42.3-Oss                  | Ja        | (r ) Ja         | Ja             |   99      | http://download.opensuse.org/distribution/leap/42.3/repo/oss/             
 9 | repo-source               | openSUSE-Leap-42.3-Source               | Nein      | ----            | ----           |   99      | http://download.opensuse.org/source/distribution/leap/42.3/repo/oss/      
10 | repo-source-non-oss       | openSUSE-Leap-42.3-Source-Non-Oss       | Nein      | ----            | ----           |   99      | http://download.opensuse.org/source/distribution/leap/42.3/repo/non-oss/  
11 | repo-update               | openSUSE-Leap-42.3-Update               | Ja        | (r ) Ja         | Ja             |   99      | http://download.opensuse.org/update/leap/42.3/oss/                        
12 | repo-update-non-oss       | openSUSE-Leap-42.3-Update-Non-Oss       | Ja        | (r ) Ja         | Ja             |   99      | http://download.opensuse.org/update/leap/42.3/non-oss/                    
martin@linux-3645:~> sudo fdisk -l 

Wir gehen davon aus, dass der lokale Systemadministrator Ihnen die
Regeln erklärt hat.  Normalerweise läuft es auf drei Regeln hinaus:

    #1) Respektieren Sie die Privatsphäre anderer.
    #2) Denken Sie nach, bevor Sie tippen.
    #3) Mit großer Macht kommt große Verantwortung.

[sudo] Passwort für root: 
Festplatte /dev/sda: 465,8 GiB, 500107862016 Bytes, 976773168 Sektoren
Einheiten: Sektoren von 1 * 512 = 512 Bytes
Sektorgröße (logisch/physikalisch): 512 Bytes / 4096 Bytes
E/A-Größe (minimal/optimal): 4096 Bytes / 4096 Bytes
Festplattenbezeichnungstyp: gpt
Festplattenbezeichner: 6229C7C4-758C-450E-9D59-F59E2AE3CB11

Gerät        Anfang      Ende  Sektoren  Größe Typ
/dev/sda1      2048    321535    319488   156M EFI-System
/dev/sda2    321536   4530175   4208640     2G Microsoft Basisdaten
/dev/sda3   4530176  46475263  41945088    20G Microsoft Basisdaten
/dev/sda4  46475264 976773119 930297856 443,6G Microsoft Basisdaten


martin@linux-3645:~> sudo sfdisk -l -uM
sfdisk: nicht unterstützte Einheit „M“
martin@linux-3645:~> sudo parted -l
Model: ATA TOSHIBA MQ01ABF0 (scsi)
Disk /dev/sda: 500GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system     Name     Flags
 1      1049kB  165MB   164MB   fat16           primary  boot
 2      165MB   2319MB  2155MB  linux-swap(v1)  primary
 3      2319MB  23,8GB  21,5GB  btrfs           primary
 4      23,8GB  500GB   476GB   xfs             primary

                                                                         

On Tue 05 Dec 2017 11:16:01 PM CST, dilbertone wrote:

hello dear Community

running into issues while installing beautiful soup version 4 via
terninal on a leap 42.3

Code:

martin@linux-3645:~> pip install beautifulsoup4
Collecting beautifulsoup4
Downloading beautifulsoup4-4.6.0-py3-none-any.whl (86kB)
100% |████████████████████████████████| 90kB 405kB/s
Installing collected packages: beautifulsoup4
Exception:
Traceback (most recent call last):
File “/usr/lib/python3.4/site-packages/pip/basecommand.py”, line 211,
in main status = self.run(options, args)
File “/usr/lib/python3.4/site-packages/pip/commands/install.py”, line
311, in run root=options.root_path,
File “/usr/lib/python3.4/site-packages/pip/req/req_set.py”, line 646,
in install **kwargs
File “/usr/lib/python3.4/site-packages/pip/req/req_install.py”, line
803, in install self.move_wheel_files(self.source_dir, root=root)
File “/usr/lib/python3.4/site-packages/pip/req/req_install.py”, line
998, in move_wheel_files isolated=self.isolated,
File “/usr/lib/python3.4/site-packages/pip/wheel.py”, line 339, in
move_wheel_files clobber(source, lib_dir, True)
File “/usr/lib/python3.4/site-packages/pip/wheel.py”, line 310, in
clobber ensure_dir(destdir)
File “/usr/lib/python3.4/site-packages/pip/utils/init.py”, line
71, in ensure_dir os.makedirs(path)
File “/usr/lib64/python3.4/os.py”, line 237, in makedirs
mkdir(name, mode)
PermissionError: [Errno 13] Permission denied:
‘/usr/lib/python3.4/site-packages/bs4’ You are using pip version 7.1.2,
however version 9.0.1 is available. You should consider upgrading via
the ‘pip install --upgrade pip’ command. martin@linux-3645:~>


what would you do ?

Hi
You need to be root user to install…


Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
openSUSE Leap 42.2|GNOME 3.20.2|4.4.92-18.36-default
If you find this post helpful and are logged into the web interface,
please show your appreciation and click on the star below… Thanks!

hello dear all - l still run into troubles…


Collecting pip                                                                                                                                                                                  
  Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB)                                                                                                                                            
    100% |████████████████████████████████| 1.3MB 176kB/s 
Installing collected packages: pip                                                                                                                                                              
  Found existing installation: pip 7.1.2                                                                                                                                                        
    Uninstalling pip-7.1.2:                                                                                                                                                                     
Exception:                                                                                                                                                                                      
Traceback (most recent call last):                                                                                                                                                              
  File "/usr/lib64/python3.4/shutil.py", line 527, in move                                                                                                                                      
    os.rename(src, real_dst)                                                                                                                                                                    
OSError: [Errno 18] Invalid cross-device link: '/usr/bin/pip' -> '/tmp/pip-8hoh9fts-uninstall/usr/bin/pip'                                                                                      
                                                                                                                                                                                                
During handling of the above exception, another exception occurred:                                                                                                                             
                                                                                                                                                                                                
Traceback (most recent call last):                                                                                                                                                              
  File "/usr/lib/python3.4/site-packages/pip/basecommand.py", line 211, in main                                                                                                                 
    status = self.run(options, args)                                                                                                                                                            
  File "/usr/lib/python3.4/site-packages/pip/commands/install.py", line 311, in run                                                                                                             
    root=options.root_path,                                                                                                                                                                     
  File "/usr/lib/python3.4/site-packages/pip/req/req_set.py", line 640, in install
    requirement.uninstall(auto_confirm=True)
  File "/usr/lib/python3.4/site-packages/pip/req/req_install.py", line 716, in uninstall
    paths_to_remove.remove(auto_confirm)
  File "/usr/lib/python3.4/site-packages/pip/req/req_uninstall.py", line 125, in remove
    renames(path, new_path)
  File "/usr/lib/python3.4/site-packages/pip/utils/__init__.py", line 315, in renames
    shutil.move(old, new)
  File "/usr/lib64/python3.4/shutil.py", line 532, in move
    os.unlink(src)
PermissionError: [Errno 13] Permission denied: '/usr/bin/pip'
You are using pip version 7.1.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

On 2017-12-05, malcolmlewis <malcolmlewis@no-mx.forums.microfocus.com> wrote:
> On Tue 05 Dec 2017 11:16:01 PM CST, dilbertone wrote:
> what would you do ?
>
> Hi
> You need to be root user to install…

I don’t wish to challenge Malcolm’s assertion, but from personal experience I think it’s a really bad idea to pip2 or
pip3 install as root as it doesn’t play nicely with package managers (e.g. zypper). For this reason I would only over
pip install this way:


sh-4.3$ pip3 install --user <package>

… to install to ~/.local/

If you really need to pip install a package as root, then I suspect that’s a symptom of a developer environment that
has not been properly thought through.

Hi
@flymail never use pip… always build rpms :wink:

@dilbertone, use the rpm?

https://software.opensuse.org/search?utf8=✓&q=beautifulsoup4&search_devel=false&search_devel=true&search_unsupported=false&baseproject=ALL

Since it looks like you want python3, then it would be;
https://software.opensuse.org/package/python3-beautifulsoup4

On 2017-12-05, dilbertone <dilbertone@no-mx.forums.microfocus.com> wrote:
> hello dear all - l still run into troubles…

Try: https://build.opensuse.org/package/show/openSUSE%3ALeap%3A42.3/python3-beautifulsoup4

On 2017-12-05, malcolmlewis <malcolmlewis@no-mx.forums.microfocus.com> wrote:
> @flymail never use pip… always build rpms :wink:

Haha! Good answer. For some libraries, however, this isn’t the most practical option (e.g. Google TensorFlow).

Hi
Doesn’t look too bad to build… if I had a Nvidia card to use… install the docker image :wink:

About 10 years ago now was building some nuclear molecular software as an rpm… compile time was around 15 hours… esp frustrating when would get hours in and then hit an error to fix… :frowning:

First, if an RPM is available and sufficient, then it’s probably the easiest way to install.

As for your attempts at installing from PyPi,

  • You should have followed the instructions in your error and upgraded pip. That can be done safely installing to your system defaults, you shouldn’t have to worry about conflicts of any type.

You are using pip version 7.1.2, however version 9.0.1 is available.
You should consider upgrading via the ‘pip install --upgrade pip’ command.

You may wish to isolate your installs, and perhaps even run different versions of Python side by side on your system. To do that, the traditional way is to install and use virtualenv. Otherwise, of course you can use virtualization to run different machines which can be customized however you wish. Installing your python app to a user directory as flymail describes is not always an option, the application may still require elevated permissions to run or code may assume a different install location.

TSU

hello dear malcolm, flymail and Tsu

many many thanks for the replies and the tipps.

i did the following :



linux-3645:/home/martin # pip install --upgrade pip                                                                                                                                             
Collecting pip                                                                                                                                                                                  
  Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB)                                                                                                                                            
    100% |████████████████████████████████| 1.3MB 155kB/s 
Installing collected packages: pip                                                                                                                                                              
  Found existing installation: pip 7.1.2                                                                                                                                                        
    Uninstalling pip-7.1.2:                                                                                                                                                                     
      Successfully uninstalled pip-7.1.2                                                                                                                                                        
Successfully installed pip-9.0.1                                                                                                                                                                
linux-3645:/home/martin # pip install beautifulsoup4
Collecting beautifulsoup4                                                                                                                                                                       
  Downloading beautifulsoup4-4.6.0-py3-none-any.whl (86kB)
    100% |████████████████████████████████| 92kB 394kB/s 
Installing collected packages: beautifulsoup4
Successfully installed beautifulsoup4-4.6.0
linux-3645:/home/martin # 


to test all - and to do some first steps i tried to run the following code;


import urllib
from bs4 import BeautifulSoup
import urlparse
import mechanize


# Set the startingpoint for the spider and initialize 
# the a mechanize browser object
url = "http://sparkbrowser.com"
br = mechanize.Browser()

# create lists for the urls in que and visited urls
urls = 
visited = 


# Since the amount of urls in the list is dynamic
#   we just let the spider go until some last url didn't
#   have new ones on the webpage
while len(urls)>0:
    try:
        br.open(urls[0])
        urls.pop(0)
        for link in br.links():
            newurl =  urlparse.urljoin(link.base_url,link.url)
            #print newurl
            if newurl not in visited and url in newurl:
                visited.append(newurl)
                urls.append(newurl)
                print newurl
    except:
        print "error"
        urls.pop(0)
       

i get the following lines back


martin@linux-3645:~/dev/python> python p1.py
Traceback (most recent call last):
File "p1.py", line 3, in <module>
from bs4 import BeautifulSoup
ImportError: No module named bs4
martin@linux-3645:~/dev/python> 

well i am not very sure what happened - probably i have installed the bs4 on the wrong path -

note - i am running python 3.
surely - i have to rewrite the above mentioned code to python 3 -

but the main thing i wonder - is why i get the errormessages…

how to check if i have installed bs4 corrrectly?

On 2017-12-06, dilbertone <dilbertone@no-mx.forums.microfocus.com> wrote:
> Code:
> --------------------
>
> import urllib
> from bs4 import BeautifulSoup
> import urlparse
> import mechanize
>
>
> # Set the startingpoint for the spider and initialize
> # the a mechanize browser object
> url = “http://sparkbrowser.com
> br = mechanize.Browser()
>
> # create lists for the urls in que and visited urls
> urls =
> visited =
>
>
> # Since the amount of urls in the list is dynamic
> # we just let the spider go until some last url didn’t
> # have new ones on the webpage
> while len(urls)>0:
> try:
> br.open(urls[0])
> urls.pop(0)
> for link in br.links():
> newurl = urlparse.urljoin(link.base_url,link.url)
> #print newurl
> if newurl not in visited and url in newurl:
> visited.append(newurl)
> urls.append(newurl)
> print newurl
> except:
> print “error”
> urls.pop(0)
>
> --------------------
>
> i get the following lines back
>
>
> Code:
> --------------------
>
> martin@linux-3645:~/dev/python> python p1.py
> Traceback (most recent call last):
> File “p1.py”, line 3, in <module>
> from bs4 import BeautifulSoup
> ImportError: No module named bs4
> martin@linux-3645:~/dev/python>
>
> --------------------
>
>
>
> well i am not very sure what happened - probably i have installed the
> bs4 on the wrong path -
>
> note - i am running python 3.
> surely - i have to rewrite the above mentioned code to python 3 -

OK so you’ve gone ahead and have installed using pip as user rather than installing an RPM as root.

Looking at you’re code, I’m not convinced you’re running Python 3 because `print newurl’ would emit a syntax error
before the import error you are seeing. Please try and run your code like this:


$ python3 p1.py

… if you get the same import error then you’re going to have to repost your code.

hello dear Flymail,

many thanks for the answer -

see here the output:


martin@linux-3645:~/dev/python>  python3 p1.py
  File "p1.py", line 31
    print newurl
               ^
SyntaxError: Missing parentheses in call to 'print'
martin@linux-3645:~/dev/python> 

love to hear from you

well i guess that i runned in some conflicts

Since opensuse comes with Python 2 and Python 3 preinstalled, we need to specify which version we are using.
If i have had installed an additional Python version, (say 3.6.3) we need to reference that, for example pip3.6 install …

how to check and make sure what is going on on the machine!?

On 2017-12-07, dilbertone <dilbertone@no-mx.forums.microfocus.com> wrote:
> see here the output:
>
>
> Code:
> --------------------
>
> martin@linux-3645:~/dev/python> python3 p1.py
> File “p1.py”, line 31
> print newurl
> ^
> SyntaxError: Missing parentheses in call to ‘print’
> martin@linux-3645:~/dev/python>
>
> --------------------
>
>
> love to hear from you

OK this proves you were previously testing p1.py using Python 2, yet it’s clear from the pip install output that
installed Beautiful Soup for Python3. Since your test program is written in Python 2 in a way that isn’t compatible with
Python 3, then you are bound the end up with problems. Rather than using a test program you can simply test whether the
Beautiful Soup package installed correctly from Python 3 console:


$ python3
>>> from bs4 import BeautifulSoup
>>> exit()

If the above import works without error then you installed BeautifulSoup correctly for Python 3.

But stepping back a bit, your approach seems have a few problems:

  1. You installed a pip package as user when it would most efficiently be done using a prebuilt RPM as root.
  2. You were convinced you were using Python 3 when you in fact you were using Python 2 (the openSUSE default).
  3. You do not seem to detect the differences in Python 2 and Python 3 syntax (they are different languages).

So you need to ask yourself some fundamental questions:

  1. Are you coding in Python 2 or 3?
  2. If you’re coding in Python 3, how much of any Python 2 code you use/have written need to be converted to Python 3?
    3, If you’re installing packages, is there is any benefit doing it on a per-user basis (which is what pip install as
    user does) especially since it will be more cumbersome to maintain during version upgrades compared to using a pre-built
    RPM installing as root (which upgrades automatically during a relevant zypper up)?

These questions, only you can answer. But you should do so before worrying too much about Beautiful Soup.

dear flymail.

first of all - many thanks for the answer:
hope i got you right - and that i have gathered all the important information.

well i have python 3 on the machine…
gardez:

.

martin@linux-3645:~/dev/python> rpm -qa | grep python
python-2.7.13-26.1.x86_64
python-numpy-1.8.0-7.1.x86_64
python3-logilab-common-1.0.2-4.2.noarch
python3-gobject-cairo-3.20.1-5.4.x86_64
python-cffi-1.5.2-3.3.x86_64
rpm-python-4.11.2-13.1.x86_64
python3-pysvn-1.8.0-4.1.x86_64
python-gobject-Gdk-3.20.1-5.6.x86_64
python3-requests-2.7.0-9.1.noarch
libpython2_7-1_0-2.7.13-26.1.x86_64
python3-wrapt-1.10.8-3.1.x86_64
python-ipaddress-1.0.18-1.1.noarch
python-cryptography-1.3.1-4.2.x86_64
python3-base-3.4.6-11.1.x86_64
python3-setuptools-18.3.2-4.4.noarch
python3-qt4-4.11.4-5.24.x86_64
python-pyudev-0.16.1-15.5.noarch
libpython2_7-1_0-32bit-2.7.13-26.1.x86_64
python-decorator-3.4.2-6.2.noarch
python-gobject2-2.28.6-29.6.x86_64
python-gtk-2.24.0-18.4.x86_64
python3-gobject-Gdk-3.20.1-5.4.x86_64
python3-gobject-3.20.1-5.4.x86_64
python3-coverage-4.3.4-1.1.x86_64
python3-sip-4.16.9-7.2.x86_64
python3-pylint-1.4.4-4.1.noarch
python-enum34-1.1.3-5.1.noarch
python3-apparmor-2.10.2-14.19.x86_64
python3-cairo-1.10.1~git20121222.5a45b0b-4.5.x86_64
python-pyOpenSSL-16.0.0-4.1.noarch
dbus-1-python3-1.2.0-9.17.x86_64
python3-bottle-0.12.8-6.1.noarch
python3-doc-3.4.6-11.1.noarch
python3-lazy-object-proxy-1.2.2-1.1.x86_64
python-pyasn1-0.1.9-12.1.noarch
python3-cups-1.9.72-6.1.x86_64
python-configobj-5.0.6-6.2.noarch
python-base-2.7.13-26.1.x86_64
python-solv-0.6.27-1.3.x86_64
python3-nose-1.3.7-9.2.noarch
python3-py-1.4.30-5.1.noarch
gimp-plugins-python-2.8.18-4.4.x86_64
python3-astroid-1.4.9.git.1489768950.31f21cd-1.1.noarch
dbus-1-python-1.2.0-9.21.x86_64
python3-simplejson-3.8.0-7.9.x86_64
python-six-1.9.0-8.4.noarch
libpython3_4m1_0-3.4.6-11.1.x86_64
python-gobject-3.20.1-5.6.x86_64
python-xml-2.7.13-26.1.x86_64
python3-tk-3.4.6-11.1.x86_64
python-idna-2.0-5.1.noarch
python3-logilab-astng-0.24.3-8.1.noarch
zypp-plugin-python-0.5-7.3.x86_64
python-pycparser-2.10-8.2.noarch
python3-pycurl-7.19.5.1-5.2.x86_64
python3-qscintilla-2.9-7.23.x86_64
python3-pip-7.1.2-7.1.noarch
python-gobject-cairo-3.20.1-5.6.x86_64
python-cairo-1.10.0-18.6.x86_64
python3-six-1.11.0-67.2.noarch
python3-cupshelpers-1.5.7-9.2.noarch
python-talloc-2.1.9-1.3.x86_64
python3-smbc-1.0.15.4-6.1.x86_64
python-talloc-32bit-2.1.9-1.3.x86_64
python3-rope-0.9.3-16.1.noarch
python3-3.4.6-11.1.x86_64
martin@linux-3645:~/dev/python>

.

i start to code in Python.

while using python 2 scripts we can do so if we call explicit “python2” or “python3”

now i try to find out what is the best way to keep pyton up to date - and how to instiall new modules /plugins

**NotE: **i use eric 5

On 2017-12-08, dilbertone <dilbertone@no-mx.forums.microfocus.com> wrote:
>
> dear flymail.
>
> first of all - many thanks for the answer:

Pleasure, but please answer my questions. Did this work:


$ python3
>>> from bs4 import BeautifulSoup
>>> exit()

On 2017-12-08, dilbertone dilbertone@no-mx.forums.microfocus.com wrote:

hope i got you right - and that i have gathered all the important
information.
well i have python 3 on the machine…
gardez:

martin@linux-3645:~/dev/python> rpm -qa | grep python

You will see that Beautiful Soup is not listed there because rather that installing the RPM as root, you installed as a
pip package as user. Why don’t you just do this:


$ su -
# zypper in python-beautifulsoup4 python3-beautifulsoup4
# exit

i start to code in Python.

Ahh okay, beginner - no problem. You might want to read: Python2orPython3 - Python Wiki

while using python 2 scripts we can do so if we call explicit “python2”
or “python3”

Good idea. I think it is slightly shameful that the openSUSE default is still python2, especially since the YaST
shouldn’t care (since it is written in Ruby). Remember that even if you install a package for one version, you have to
also install it for the other (as the `zypper’ call above does).

> now i try to find out what is the best way to keep pyton up to date -
> and how to instiall new modules /plugins

Since you’re a beginner I’m going to say it: use Python 3 and forget Python 2. Sure, there might be a small handful of
packages that are Python-2 only, but if they still are at this stage they are probably not worth using. If you are
using old Python 2 code, convert it: you can do it either manually or use 2to3:
25.4. 2to3 - Automated Python 2 to 3 code translation — Python 2.7.18 documentation .

> *NotE: *i use eric 5

If you’re a beginner, I would advise against an IDE like eric 5 because they hide a lot of what is going on in the
background. You might want to read Learn Python the Hard Way . If you’re not familiar with Vim
or emacs, I would advise using kate (in KDE) or gedit (in GNOME). In any case, you will want to run Python from console
but bear in mind within a Python shell, versions 2 and 3 have different ways of executing Python scripts:


$ python2
>>> execfile("yourscript.py")
>>> exit()
$ python3
>>> exec(open("yourscript.py").read())
>>> exit()

HTH.

hello dear Flymail - see here the results:

and many thanks for your continued support.

Passwort: 
linux-3645:/home/martin/dev/php # zypper in python-beautifulsoup4 python3-beautifulsoup4
Metadaten von Repository 'ecsos' abrufen ............................................................................[fertig]
Cache für Repository 'ecsos' erzeugen ...............................................................................[fertig]
Metadaten von Repository 'Packman Repository' abrufen ...............................................................[fertig]
Cache für Repository 'Packman Repository' erzeugen ..................................................................[fertig]
Metadaten von Repository 'packman' abrufen ..........................................................................[fertig]
Cache für Repository 'packman' erzeugen .............................................................................[fertig]
Metadaten von Repository 'openSUSE-Leap-42.3-Update' abrufen ........................................................[fertig]
Cache für Repository 'openSUSE-Leap-42.3-Update' erzeugen ...........................................................[fertig]
Repository-Daten werden geladen...
Installierte Pakete werden gelesen...
Paketabhängigkeiten werden aufgelöst...

Die folgenden 14 NEUEN Pakete werden installiert:
  python3-Babel python3-beautifulsoup4 python3-cssselect python3-Genshi python3-html5lib python3-lxml python3-pytz
  python-Babel python-beautifulsoup4 python-cssselect python-Genshi python-html5lib python-lxml python-pytz

Die folgenden 4 empfohlenen Pakete wurden automatisch gewählt:
  python3-Genshi python3-lxml python-Genshi python-lxml

14 neue Pakete zu installieren.
Gesamtgröße des Downloads: 10,0 MiB. Bereits im Cache gespeichert: 0 B. Nach der Operation werden zusätzlich 45,9 MiB belegt.
Fortfahren? [j/n/...? zeigt alle Optionen] (j): j
Paket python-cssselect-1.0.3-22.1.noarch abrufen                                       (1/14),  32,3 KiB (162,6 KiB entpackt)
Abrufen: python-cssselect-1.0.3-22.1.noarch.rpm ........................................................[fertig (40,9 KiB/s)]
Paket python3-cssselect-1.0.3-22.1.noarch abrufen                                      (2/14),  33,3 KiB (153,1 KiB entpackt)
Abrufen: python3-cssselect-1.0.3-22.1.noarch.rpm .......................................................[fertig (52,8 KiB/s)]
Paket python-lxml-4.0.0-95.4.x86_64 abrufen                                            (3/14),   1,3 MiB (  5,0 MiB entpackt)
Abrufen: python-lxml-4.0.0-95.4.x86_64.rpm .............................................................[fertig (44,4 KiB/s)]
Paket python3-lxml-4.0.0-95.4.x86_64 abrufen                                           (4/14),   1,3 MiB (  5,1 MiB entpackt)
Abrufen: python3-lxml-4.0.0-95.4.x86_64.rpm ............................................................[fertig (40,0 KiB/s)]
Paket python-pytz-2016.10-1.4.noarch abrufen                                           (5/14),  42,9 KiB (193,3 KiB entpackt)
Abrufen: python-pytz-2016.10-1.4.noarch.rpm ............................................................[fertig (26,1 KiB/s)]
Paket python3-pytz-2015.6-4.1.noarch abrufen                                           (6/14), 180,0 KiB (668,1 KiB entpackt)
Abrufen: python3-pytz-2015.6-4.1.noarch.rpm ............................................................[fertig (28,0 KiB/s)]
Paket python-Babel-2.3.4-3.4.noarch abrufen                                            (7/14),   4,0 MiB ( 19,6 MiB entpackt)
Abrufen: python-Babel-2.3.4-3.4.noarch.rpm .........................<46%>====================================- (44,9 KiB/s)]Abrufen: python-Babel-2.3.4-3.4.noarch.rpm .........................<46%>====================================\ (30,2 KiB/s)]Abrufen: python-Babel-2.3.4-3.4.noarch.rpm .............................................................[fertig (15,4 KiB/s)]
Paket python3-Babel-1.3-6.3.noarch abrufen                                             (8/14),   2,0 MiB (  8,8 MiB entpackt)
Abrufen: python3-Babel-1.3-6.3.noarch.rpm ..............................................................[fertig (14,2 KiB/s)]
Paket python-Genshi-0.7-6.4.x86_64 abrufen                                             (9/14), 270,5 KiB (  1,8 MiB entpackt)
Abrufen: python-Genshi-0.7-6.4.x86_64.rpm ..............................................................[fertig (51,1 KiB/s)]
Paket python3-Genshi-0.7-4.1.x86_64 abrufen                                           (10/14), 280,2 KiB (  1,7 MiB entpackt)
Abrufen: python3-Genshi-0.7-4.1.x86_64.rpm .............................................................[fertig (55,3 KiB/s)]
Paket python-html5lib-0.9999999-3.4.noarch abrufen                                    (11/14), 178,7 KiB (920,5 KiB entpackt)
Abrufen: python-html5lib-0.9999999-3.4.noarch.rpm .......................................................[fertig (5,6 KiB/s)]
Paket python3-html5lib-0.999999-4.1.noarch abrufen                                    (12/14), 183,8 KiB (871,2 KiB entpackt)
Abrufen: python3-html5lib-0.999999-4.1.noarch.rpm ......................................................[fertig (19,4 KiB/s)]
Paket python-beautifulsoup4-4.3.2-9.7.noarch abrufen                                  (13/14), 126,0 KiB (554,2 KiB entpackt)
Abrufen: python-beautifulsoup4-4.3.2-9.7.noarch.rpm ....................................................[fertig (12,0 KiB/s)]
Paket python3-beautifulsoup4-4.4.0-4.1.noarch abrufen                                 (14/14), 142,3 KiB (573,1 KiB entpackt)
Abrufen: python3-beautifulsoup4-4.4.0-4.1.noarch.rpm ...................................................[fertig (15,1 KiB/s)]
Überprüfung auf Dateikonflikte läuft: ...............................................................................[fertig]
( 1/14) Installieren: python-cssselect-1.0.3-22.1.noarch ............................................................[fertig]
( 2/14) Installieren: python3-cssselect-1.0.3-22.1.noarch ...........................................................[fertig]
( 3/14) Installieren: python-lxml-4.0.0-95.4.x86_64 .................................................................[fertig]
( 4/14) Installieren: python3-lxml-4.0.0-95.4.x86_64 ................................................................[fertig]
( 5/14) Installieren: python-pytz-2016.10-1.4.noarch ................................................................[fertig]
( 6/14) Installieren: python3-pytz-2015.6-4.1.noarch ................................................................[fertig]
( 7/14) Installieren: python-Babel-2.3.4-3.4.noarch .................................................................[fertig]
Zusätzliche rpm-Ausgabe:
update-alternatives: using /usr/bin/pybabel-2.7 to provide /usr/bin/pybabel (pybabel) in auto mode


( 8/14) Installieren: python3-Babel-1.3-6.3.noarch ..................................................................[fertig]
Zusätzliche rpm-Ausgabe:
update-alternatives: using /usr/bin/pybabel-3.4 to provide /usr/bin/pybabel (pybabel) in auto mode


( 9/14) Installieren: python-Genshi-0.7-6.4.x86_64 ..................................................................[fertig]
(10/14) Installieren: python3-Genshi-0.7-4.1.x86_64 .................................................................[fertig]
(11/14) Installieren: python-html5lib-0.9999999-3.4.noarch ..........................................................[fertig]
(12/14) Installieren: python3-html5lib-0.999999-4.1.noarch ..........................................................[fertig]
(13/14) Installieren: python-beautifulsoup4-4.3.2-9.7.noarch ........................................................[fertig]
(14/14) Installieren: python3-beautifulsoup4-4.4.0-4.1.noarch .......................................................[fertig]
linux-3645:/home/martin/dev/php # 

So far so good: many thanks der buddy for the continued help:

after having done this - i tried out my new installation while

**Using python requests module to login on an Wordpress based website
**

**what happened: **I’m trying to login to a Wordpress based website using python’s request module and beautifulsoup4.
It seems like the code fails to sucessfully login. Also, there is no csrf token on the website. How do I sucessfully login to the website?


import requests
import bs4 as bs
with requests.session() as c:
    link="https://gpldl.com/sign-in/" #link of the webpage to be logged in
    initial=c.get(link) #passing the get request
    login_data={"log":"*****","pwd":"******"} #the login data from any account on the site. Stars must be replaced with username and password
    page_login=c.post(link, data=login_data) #posting the login data into the link
    print(page_login) #checking status of requested page
    page=c.get("https://gpldl.com/my-gpldl-account/") #requesting source code of logged in page
    good_data = bs.BeautifulSoup(page.content, "lxml") #parsing it with BS4
    print(good_data.title) #printing this gives the title that is got from the page when accessed from an logged-out account
 

i got back:

martin@linux-3645:~/dev/python> python w1.py
Traceback (most recent call last):
  File "w1.py", line 1, in <module>
    import requests
ImportError: No module named requests

well: Requests is not a built in module (does not come with the default python installation), so you will have to install it:
OSX/Linux

i used this command:

Use $ sudo pip install requests

if we have pip installed

Alternatively we can also use

 sudo easy_install -U requests 

if we have easy_install installed.


martin@linux-3645:~/dev/python> sudo pip install requests
Requirement already satisfied: requests in /usr/lib/python3.4/site-packages
martin@linux-3645:~/dev/python> 

btw - see this …:

martin@linux-3645:~/dev/python> sudo pip install requests 
Requirement already satisfied: requests in /usr/lib/python3.4/site-packages 
martin@linux-3645:~/dev/python>

so what can i do now? - i thnk that i will open a new thread - since this is a new topic…

greetings dilbertone