Which Python version to use for using BeautifulSoup and urllib? - python

I'm working on web crawling using Python. I had issues while using Python version 3. So I wanted to know which version of Python is suitable for web crawling.

I think there is definitely a counter-argument to making the move to Python 2.7. There is no reason that I can think of, particularly for web crawling, that you would need to revert to Python 2.7.
BeautifulSoup 4 and lxml are both fully ported to Python 3.5.
urllib is fully functional in Python 3.5. You should be aware that there are differences in the implementation of urllib in Python 2.7 and Python 3.5.
However, I would suggest you use the Requests package instead of urllib. Here is a post highlighting some of their differences.
If you need to load pages that require javascript, Selenium also works in Python 3.5. Selenium can also support headless browsing (e.g., PhantomJS).
Also, here is an official post from Python that can help guide you to your decision.

If you do opt to install one of the standard Python distributions,
make sure you have Python 2.7.3 or later, but do not use Python 3.0 or
later; these versions are, of course, the cutting edge versions, but
many of the packages we will be using do not yet have Python 3.X
support, and until they do, 3.X is not that appealing. For a good
discussion of what is and is not available in Python 3.X, see Choosing
Python versions.
Got this of a website which introduces and discusses web-cralling for Python. I would suggest you take their advice. I have also experienced that Python 2.7.* is the best for application at the moment for using additional packages.

Related

Using older version of python with Py-Script

Would anybody know how to change the version I use in Py-Script? Currently my Py-Script is using python 3.10, but I would like to be able to use python 3.6.
I had python 3.10 and 3.6 installed, so i tried removing 3.10, but that didn't work, as I also expected, but other than that, I have no clue how to and have had no luck finding any information on the topic online.
I'm quite new to programming, so any help would be greatly appreciated!
You cannot easily change the Python version. Python is included with Pyodide which PyScript loads. Changing the version would require rebuilding Pyodide.
Note: I am not sure if it would be possible to use vanilla Python 3.6 with the current version of Pyodide.
Improve your code to work with Pyodide's bundled version of Python.

Are python 3.6.9 and python 3.7.4 compatible?

My friend and I are working on a project. We both setup our vitualenvs but I use python 3.6.9 while my friend is using python 3.7.4. Will this cause issues during development?
Will this cause issues during development?
It depends. If you agree to stick to the features that are available in 3.6 it will probably be fine.
But it means for example you can't use dataclasses, and you'd have to be careful when using asyncio.
I would advise you both to use the Python documentation for 3.6. That would lessen the chance of introducing an incompatible feature.
You may want to be bit cautious and refer to
https://www.python.org/dev/peps/pep-0387/

python3.7 biopython, how to learn python3 and still use biopython

I'm very new to python and biopython, currently using a mac. I have python v2.7 and v3.7, and I would like to be learning with python3. Biopython only works on v2.7. Is it worth installing python V3.4 as well as these other 2 versions so I can learn python3 and use biopython? Or remove python3.7 and add 3.4? Even if I install python3.4 will biopython work if it was installed prior? Very confused biologist here.
Firstly, check out this page: https://biopython.org/wiki/Download
You don't have to worry about biopython being bound to a specific version of python - you can use it with either v2.7 or v3.4/v3.5/v3.6. You can also have multiple version installed on your system but I recommend you to focus on digging deeper into one of them. Personally, I work now for several years with python3.x (at the moment 3.6) but I know a lot of people sticking to v2.7.
Having also a bioinformatics background, one thing that I can highly recommend you at the beginning of your journey is taking a course such as:
https://www.coursera.org/specializations/python
There is also a bunch of free tutorials on youtube - you will easily find one that fits your needs by searching for "python tutorial" or "python getting started".
Get yourself comfortable with the language, check out the basics such as data structures, databases, and data visualization. Check also some "python cheat sheets" - they can help you pick up the basic concepts of the language.
All the best and keep on coding!
From the biopython installation document:
Biopython is designed to work with Python 2.5 to 2.7 inclusive. Python 2.7 is the final 2.x series release, and this would be our recommended version (assuming all other Python libraries you plan to use support it).
Upgrading bug-fix releases (for example. 2.6.1 to 2.6.2) is incredibly easy and won’t require any re-installation of libraries.
Upgrading between versions (e.g. 2.6 to 2.7) is more time consuming since you need to re-install all libraries you have added to python.
As of Biopython 1.62 we officially support Python 3, specifically Python 3.3. Python 3.0, 3.1 and 3.2 will not be supported.
Also from the Biopython website:
Python 2.7, 3.4, 3.5, or 3.6 or PyPy, including the Python development header files like python.h
So biopython is inconsistent with their documentation.
I think your best option is to download either the latest version of Python 2 or 3 and see if it works.

MacOS Sierra 10.12.1 - selenium - which version of Python?

I plan to install Python and Selenium on MacOS 10.12.1.
What would be the better choice - Python 2.7 or 3.6.5? On windows I use 2.7, because I read that it works faster. But are there any proven obstacles while working with Python 3 and Selenium on Mac?
I have been using Python 3 for quite a long time now. There is not really a performance issue that is quite noticeable. I would suggest Python 3 or which ever is the newer one because as they keep developing they will be adding new things that you might need and remove some older vulnerabilities. I would suggest you upgrade to Python 3. There might be some getting used to the new syntax but it can be quickly come over as you keep developing.

What Python 3 version for my Django project

I will try to port my Python 2.7 with Django to Python 3. But now my question is what version is the most stable one today? I've heard people use 3.2 and 3.4 and recommend it. But now I'm asking you guys.
What version is the most stable one today?
If you go to their downloads page, you will find the following statement (my emphasis):
We recommend using the latest version of Python 3 [...]
I've been using Python 3.4.3+ in a Django 1.8.2 project without issues and I don't see why you should run into problems here.
However, if you do run into issues, you should file a bug.
What version is the most stable one today?
Whatever version shows up as the recommended download in the python homepage should be considered stable. If that happens to be v3.5, then you should use that.
Python's version are quite stable, but you have to check is virtualenv on your OS is handled already by particular Python's version eg. 3.5.0 is not yet prepared for it. I recommend you 3.4.x, which I use on my own without any problems.
You may check for 'What Python version can I use with Django?' in official documentation here and here faq which lists which Python version is supported to which Django version

Categories