Different version of python installed [duplicate] - python

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
I'm starting a new open-source software in Python, and I'm wondering whether I should use Python 2.x or Python 3.x.
It will include a heavy GUI, complex scientific algorithms dealing with large amounts of data. I'll need at least Numpy, Scipy, PyQT4, PyOpenGL, h5py, optionaly Matplotlib. It should first be released in 2013, with updates and extensions during the next few years.
It will be used by scientists that do not necessarily have a background in computer science, on a wide variety of computers (Linux, Windows, Mac...). Some machines may be old.
If I choose Python 3.x, I fear that the software and the third-party libraries may be more complicated to install, especially on old systems where Python 2.x is already installed. It would be better if RPM-like packages (or Windows installers) for Python and the external libraries were available on most systems, such that one doesn't need to compile everything. Also, I don't know if the 3.x branch is mature enough.
If I choose Python 2.x, I may need to port the software to Python 3.x in the near future if the 2.x branch becomes deprecated (when will that happen?).
What would be the best option?

UPDATE: My original answer was given in 2012. However, now, years later, the answer should and must be Python 3.
This wiki discusses exactly your question: Should I use Python 2 or Python 3 for my development activity?
This is a very large subjective part to this question which depends on exactly your specific situation and constraints.
IMO, however, if you can't be sure that all 3rd party libraries you need will work with Python v3.x I would stick with Python 2.x but try to write code to be as compatible with Python 3.x as much possible (e.g., print() etc) so that if you ever need or want to migrate to v3 your work won't be so challenging. And of course there are documentation and tools on moving from version 2 to 3. And this on porting v2 code to v3.
This will especially be the case on systems where you don't have control or can't install newer versions of Python or customize the installation of 3rd party software/libraries.
Given that your software will be run on a wide variety of systems (Linux, Windows, Mac ..) and by a number of different users I still think that v2 is more of a common denominator these days.
So, short-attention-span summary: Use version 2.x but perpare your code for v3.x
Finally, if you put this search string "[python] version 3 or 2" into the SO search box, you'll find a number of related posts:

Python 3. (The answer to this question has changed!)
Python 2 is for legacy projects. New projects should lean towards Python 3.
The reason for this is that Python 3 (now 3.6) is roughly getting a new release each year. It has also been stable for many years (is in its tenth release year!). In contrast, Python 2 (still 2.7) has changed little in the last several years and will continue to grow stagnant.
For more information:
https://wiki.python.org/moin/Python2orPython3/

I agree with Levon.
With those requirements, I wouldn't risk starting in Python3 yet, but you should write your code taking as many of Python3 changes into consideration as possible.
See this question Writing Python 2.7 code that is as close to Python 3.x syntax as possible as it might help you with some imports and standards that you can use to make your code as future-proof as possible.
Also, if you're running in a variety of systems, you'd need to either distribute your version of python bundled in the application, or trust the installation of the user. Most OS's (non-windows), come with a 2.x flavor of Python installed, and it's not trivial for a non-techie user to upgrade to 3.x without the possibility of breaking the system.

Related

Are Python libraries os specific [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
Why does some Python libraries fail to install on different Operating System. If I compare it with Java, python has wheel and egg (which is discarded), and once I have jar, I can run it on any System irrespective of OS but in case of Python there are some libraries which are clearly mentioned to be supported on some specific OS. Python too has a byte code but why is it OS specific( Tensorflow is supported on Ubuntu but when I try to install it on cnetos I get errors), isn't it supposed to work like Java wherein i can just download the binaries and simply execute the code.
Also when I do pip install some libraries is it compiling the source code. I know there are various implementation of Python (CPython, JPython etc)
I have read the articles around Python from various links and the one I found useful is http://www.techdarting.com/2014/04/python-compiled-or-interpreted-language.html
There are two kinds of libraries, for both languages: the ones written in Python (or Java), and the ones that link against native code (with native extensions for Python, or JNI in Java). The native ones might have requirements that cannot be satisfied in certain environments. It is just that you have run into many more native libraries for Python than for Java. Usually native code is used either to access non-standard hardware (obviously platform-dependent) that is not available from the bytecode (that is designed as platform-independent), or because native code is faster than bytecode. Python being rather slower than Java is one of the reasons native libraries are more common in the Python world than in the Java world. (E.g. one common piece of Java code that is platform-dependent is Eclipse; one reason is that it uses native graphical libraries rather than Java's.)

My python IDE and worried about versions

I just got Pycharm Community version and Python version2. something. I just wanna know if i can have a problem with the versions. Also What is the best way to use Python for?
PyCharm: Simplifying things a bit, PyCharm is just a fancy editor. Unless you have it deeply ingrained into your workflow, you can always switch to a different editor, should PyCharm cease to fulfill your needs.
Python 2 is not the newest version of the language; that would be Python 3.6 as of now (that is, the summer of 2017). So, theoretically, if you start to write lots and lots of code and then later decide, when Python 2 is no longer maintained and third-party libraries drop their support, that all your code should now be compatible with Python 3, you may find yourself in the uncomfortable situation that you suddenly have to port all your code to Python 3, but you lack the ressources to do so. If you recently started programming in Python and have no prior investment, you might consider using Python 3 instead.
Otherwise, simply write modern Python. If you do a serious project, write unittests. Then porting to Python 3 is doable.
What is the best way to use Python for? Python is a multi-purpose language used in all kinds of contexts. It is often used in the scientific community. But it's also used a lot for web services, in education, as an embedded scripting language and many of other use cases. What are your interests? Just use Python for that.

Why is there a python 3.x branch when we have continued development on the 2.x branch? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
The Python 2.x environment is stable and well-utilized by the current python community. And yet there is also a python 3.x branch of the language.
Why have we started a python 3.x branch? Does that imply that we are going to deprecate the 2.x branch anytime soon?
Can an experienced python developer explain the differences between the two and offer the best choice for a newbie who wants to learn the language?
If python 3.x is gonna be used longer, Are we solving the existing problems in 2.x like,
GIL issue for multithreading support?
Sorry if this question seems really basic but I would really like to learn!
Yes, the 2.x series is already deprecated in the sense that there will be no version 2.8 - 2.7 was the last 2.x major version.
The reason for the 2 to 3 change is because the 3.x branch makes certain backwards-incompatible changes (e.g. differentiating bytes and str, making print() a function rather than a statement, et cetera). This breaks compatibility with programs written for Python 2.x and as such requires special handling.
All new feature development is occurring in the 3.x branch. Some changes are being backported to 2.7.x versions, but that will only happen for so long - eventually, Python 2.7 will stop being maintained.
Python 3 breaks compatibility with Python 2.
This is pretty normal release management. When incompatible changes are introduced, previous major release branch is maintained for a period of time, sometimes a long one, alongside the new branch.

Python 2.7 or Python 3 (for speed)? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
I've looked around for answers and much seems to be old or outdated. Has Python 3 been updated yet so that it's decently faster than Python 2.7 or am I still better off sticking with my workable code?
The issue isn't about speed -- they're either the same speed or Python 3.x is faster (depending on which benchmarks you look at). More specifically, Python 2 used to be faster, but apparently, they're on par with each other now (?). See the comments and this slide deck (towards the back).
The core devs are also actively working on optimizing Python 3 -- each new release of Python 3 has been faster than the last. You can keep abreast of the latest proposals and ideas on optimizing Python (as well as the many complications) by monitoring the python-dev mailing list.
Rather, the reason many people used to give for not updated is because when Python 3 came out, and for several years after, the majority of Python libraries were not updated to work on Python 3.x. However, thankfully, this situation is vastly improved today -- the majority of 3rd party libraries are now Python 3 compatible.
The Python FAQ contains more info. You can also check the Python Wall of Superpowers or Py3 Readiness to get an overview of which popular Python libraries are currently compatible with Python 3.
Update: (Summer 2017)
I feel somewhat obligated to note that support for Python 2 is formally ending in 2020.
Many 3rd party libraries are also planning on following suit -- a large subset of the scientific ecosystem (e.g. matplotlib, pandas, ipython) are planning on dropping support for Python 2 in 2020, Django is dropping support... I wouldn't be surprised if other libraries do the same.
So, if you're interested in making sure you can use the latest and greatest features in either Python or your favorite library, you should look into migrating to Python 3 sooner rather than later.
Here are some guides on converting Python 2 to 3 code:
https://docs.python.org/3/howto/pyporting.html
http://python3porting.com/
https://eev.ee/blog/2016/07/31/python-faq-how-do-i-port-to-python-3/
FYI, here's a performance benchmark comparing Python 2.7 with Python 3.3. Python 3.3 comes faster than Python 2.7.
Python 3.3 included an optimization for Unicode strings that reduced their memory consumption. That might translate into faster code if more of it fits into cache.
Really the only way to know is to benchmark your most critical code in both and see what the difference is.
The necessity of Libraries for your applications will determine whether Python3 or Pyhton2 is better.

Should I Start With Python 3.0? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
Recently I decided to expand my programming horizons and learn the python programming language. While I have used python a little bit for classes in college and for a project or two at work I am by no means an expert. My question is as follows: should I bother with the 2.x releases or should I jump straight to 3.0? I am leaning towards 3.0 since I will be programming applications more for personal/learning use, but I wanted to see if there were any good arguments against it before I began.
Absolutely not 3.0 - 3.1 is out and is stabler, better, faster in every respect; it makes absolutely no sense to start with 3.0 at this time, if you want to take up the 3 series it should on all accounts be 3.1.
As for 2.6 vs 3.1, 3.1 is a better language (especially because some cruft was removed that had accumulated over the years but has to stay in 2.* for backwards compatibility) but all the rest of the ecosystem (from extensions to tools, from books to collective knowledge) is still very much in favor of 2.6 -- if you don't care about being able to use (e.g.) certain GUIs or scientific extensions, deploy on App Engine, script Windows with COM, have a spiffy third party IDE, and so on, 3.1 is advisable, but if you care about such things, still 2.* for now.
Use 3.1
Why?
1) Because as long as everyone is still using 2.6, the libraries will have less reasons to migrate to 3.1. As long as those libraries are not ported to 3.1, you are stuck with the choice of either not using the strengths of 3.1, or only doing the jobs half way by using the hackish solution of using a back-ported feature set. Be a forward thinker and help push Python forward.
2) If you learn and use 3.1 now, you wont have to relearn it later when the mass port is complete. I know some people say you wont have to learn much, but why learn the old crap at all? Python itself is moving towards 3.1, the libraries will move toward 3.1, and it sucks to have to play catch-up and relearn a language you are already using.
3) 3.1 is all around a better language, more stable and more consistent than 2.6... this is normal. The lessons learned from 2.6 were all poured into 3.1 to make it better. It is a process called PROGRESS. This is why nobody still uses Windows 3.1. It is the way things move FORWARD. Why else do you think they went to the trouble of back porting a feature set in the first place?
4) If you are learning Python, and learn 2.6, then by the time you are really comfortable with the language, the ports will be out, and you will have to learn the libraries, and the language all over again. If you start with 3.1, then by the time you are comfortable with the language, the ports will be out, and then you can learn the libraries that you are interested in. It is a smoother process.
5) To be a better developer. If you have to learn and relearn the same things, your understanding will not be very deep. By learning this language, and its libraries only once, you will have more time to work with them rather than relearning syntax. This allows you to understand them better. If you are really missing some pieces by forgoing on the libraries? WRITE THEM. You will probably not need an entire library, and can usually write only those pieces that you need, and develop tools for yourself. This, again, helps you understand the language better, and more deeply.
Short answer: Start with Python 2.6.
Why: Programming is more fun and useful when you can leverage the work of others. This means using 3rd party libraries often. Many of the popular libraries for Python don't have 3.x support yet. PIL and NumPy/SciPy come to mind. My favorite interpreter, ipython, also doesn't work with 3.0 yet. Many unit testing frameworks and web frameworks are also not on 3.0 yet.
So if you start out in 3.x many doors will be closed to you, at least until 3.x porting takes on steam. There are admittedly a lot of nice features in Python 3.x, but some of them have been backported to 2.6 and some more will make it into 2.7. So stick with 2.6 for now, and re-evaluate 3.x in a year's time or so.
I think that you will be better served going straight into 3.0. Unless you have a legacy codebase to contend with, there are very few advantages to learning the 2.xx ways of doing things.
In the Python world (as in most others, really), releases do tend to take a while to migrate down to all of the subprojects, but if you ever find the need to transition back to 2.xx, I don't think you'll find relearning things to be particularly painful.
You should go with the latest release of any programming language you learn unless you have a specific reason not to. Since you don't have an existing project that won't work with Python 3.0, you should feel free to use the newest version.
Use python 3.1, Luke.
Python 3.1 should not be used until other libraries have caught up with support for it.
You should use 2.6 now. It has several 3.x features back-ported to it, so that migrating to 3.x won't be difficult later on, and you won't learn obsolete practices.
The good news is that it's not really that tough to learn both Python 2.x and 3.x. You can install the latest 2.x version as the version registered with the system to run Python scripts by default, but also install the latest 3.x version to explicitly kick off when you want to. That's what I have on my Windows Vista system.
Then, the key document for learning the differences between the 2.x and 3.x versions is:
http://docs.python.org/3.1/whatsnew/3.0.html
If you read Python learning materials out there which are based on 2.x and also refer to that "What’s New In Python 3.0" link above, you'll get an understanding of how things changed. Also see the other whats new docs, like for the differences between 3.0 and 3.1, but the link above is the main one to understand the 2.x vs. 3.x changes.

Categories

Resources