Python Forum
how to check if i have installed python correct?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to check if i have installed python correct?
#1
hello dear python-experts,

i am apollo - pretty new to python. i have installed python on my opensuse leap 42.3. box:

afterwards i have installed bs4 - see below.
note - i did this as root. Hopefully this is correct.

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 if all went all right i tried the following:
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 = [url]
visited = [url]


# 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


[email protected]:~/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
[email protected]:~/dev/python> 
sure thing - the above mentioned code is version 2 based.

but i guess that i have done some kind of misconfiguration in the installation of python?!?

probably i have choosen some wrong paths...

love to hear from you
Reply
#2
Try using pip3 install ... . Since opensuse comes with Python 2 and Python 3 preinstalled, you you need to specify which version you are using. If you you installed an additional Python version, (say 3.6.3) you need to reference that, for example pip3.6 install ...
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply
#3
hello dear - sparkz - alot,

many thanks - i runned a final test - now i am going to to what you adviced. Many thanks again


[email protected]:~/dev/python>  python3 p1.py
  File "p1.py", line 31
    print newurl
               ^
SyntaxError: Missing parentheses in call to 'print'
[email protected]:~/dev/python>
how to check and make sure what is going on on the machine!?
Reply
#4
apollo, there is a change in how print is used in Python 3 as compared to Python 2. Here is a quick summary.
print newurl is for Python 2, so you will need to change that to:
print(newurl). Same with other print statement you have.
Reply
#5
hello dear J crater

many thanks for the heads up and the tipps regarding the difference of Python 2 and 3. I appreciatate this:

one word regarding the system i run here:


1. i have installed a pip package as user when it would most efficiently be done using a prebuilt RPM as root.
2. i thougt that i were using Python 3 - but in fact there is Python 2 (the openSUSE default).


but wait: I have installed Eric verison 5 on my openSuse version 42.3:

and if i open eric i see the following

Quote:Python 3.4.6 (default, Mar 22 2017, 12:26:13) [GCC] auf linux-3645, Standard>
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Bug Selenium installed but not installed? NoNameoN 9 3,272 Feb-19-2021, 11:31 AM
Last Post: NoNameoN
  Python web crawler and input command not having the correct results see below for mor samlee916 0 1,045 Jul-25-2020, 08:24 PM
Last Post: samlee916

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020