Python Forum
Problems with moving from 3.5 to 3.6
Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problems with moving from 3.5 to 3.6
#1
So I have Ubuntu and I wanted to try Python 3.6, so I installed it using "apt altinstall" command.

After playing around with it, I decided to see how it executes my earlier scripts and opened a webscraper of mine, which uses requests and beautifulsoup.

And problems appeared. Python 3.6 does not see the "requests" module. The module is located in the folder "/usr/lib/python3/dist-packages/" which by default is not a part of Python 3.6's sys.path. After some googling around I still don't know how to make python 3.6 permanently know that libraries should be sought in that folder.

Okay, so I added to my script the line "import sys; sys.path.append('/usr/lib/python3/dist-packages/')" which solved the problem (in a rather ugly way), but now another problem appeared: beautifulsoup does not know what lxml is anymore.


Quote:bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library?

I am at a loss. What I am supposed to do with those problems?
Reply
#2
Quote:Python 3.6 does not see the "requests" module. The module is located in the folder "/usr/lib/python3/dist-packages/"
This could cause problems in the future. You are basically re-using python3.5 3rd party modules for python3.6. This appears to have no effect on request or bs4 modules, but can on others. You should strive to install separate modules, one for each python installation. 


Quote:beautifulsoup does not know what lxml is anymore.
You can either install lxml to your python3.6
https://pypi.python.org/pypi/lxml

or you can change your parser from
Quote:
soup = BeautifulSoup(html, "lxml")
to this
soup = BeautifulSoup(html, "html.parser")
Recommended Tutorials:
Reply
#3
Where are Python3.6 modules located. What if you just create link to /usr/lib/python3/dist-packages/

Something like 

$ sudo ln -s /usr/lib/python3/dist-packages dist_packages
and put it in  /usr/lib/python36/

For instance
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#4
So for fifteen minutes I was just copy-pasting folders between python3 and python3.6 trying to choose appropriate place for them. Somehow it feels wrong. It seems like I'm doing machine's job where machine is supposed to be more competent.

A failed to make BeautifulSoup(html, "lxml") working and had to replace it with BeautifulSoup(html, "html.parser"). The script is working now.

I think sooner or later I'll need lxml, so I'd appreciate if somebody told be how to make it working.
Reply
#5
Metulburr advised you already on what you ought to do...Install any needed third party mods for 3.6 in 3.6's location. Copy and Paste is not the correct way to do it., for the reasons he gave. Also check your /usr/bin/ and see if you now have a "pip36" in there. I only have 2.7 and 3.5 on my machine, so I don't know if a new pip was created.
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
#6
I don't know how to install mods for 3.6 in 3.6's location.

Executing "pip3.6 install /home/hellerick/Documents/Install/lxml-3.7.1-cp35-cp35m-manylinux1_x86_64.whl" returns
Quote:pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
lxml-3.7.1-cp35-cp35m-manylinux1_x86_64.whl is not a supported wheel on this platform.

This page does not mention anything with "cp36". Does it mean I cannot install lxml for python 3.6?
Reply
#7
Quote:pip3.6 install /home/hellerick/Documents/Install/lxml-3.7.1-cp35-cp35m-manylinux1_x86_64.whl
First of all this wheel is for python3.5. And second of all all you should have to do is this
pip3.6 install lxml
and it will find the proper wheel for you (assuming there is one for 3.6)

Quote:This page does not mention anything with "cp36". Does it mean I cannot install lxml for python 3.6?
This is one of the main reasons why programmers dont use the latest software. I personally would just use python3.5 for awhile. I wont move up to 3.6 until 3.7 is out. By that time most 3rd party libs should easily have numerous versions for 3.6. I just started using 3.5 recently. Before that i was using 3.2. a few months ago and before.
Recommended Tutorials:
Reply
#8
Uh, okay, I'll try to survive.

Thanks, everyone!
Reply


Forum Jump:

User Panel Messages

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