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.)
Related
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.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
Each Python distribution I found contains a lot of libs I don't need (numpy, scipy, PyQt etc.) I am looking for portable CPython analogue that doesn't require installation, doesn't touch anything but its directory, and is small to download over a slow or metered Internet connection.
I don't mean specifically http://portablepython.com/. I can choose packages to unpack manually. There is no way to make installer silent.
There is https://winpython.github.io/. I have to unpack 1.5GB first and uninstall unused packages.
PyPy -- http://pypy.org/. As far as I understand, is portable too but it seems it don't support all packages I need. (I will investigate that later.)
Why I need that.
Project is required to be copy-deployed on Windows machines with no prerequisites. Second, building project directory with Python interpreter and packages (including mine) must be completely automated and should use project's repository and files that can be easily downloaded from Internet.
suggestion:
install a winpython,
remove all packages you don't want,
add all packages you want,
zip the result, and unzip it on any PCs.
There is Portable Python. But as you said, it comes with some extra (and very useful) libs. What's wrong with this extra libs? I mean, if you will not use, just leave there.
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 9 years ago.
Improve this question
I want to know if there are ways to compile C, C++ and Python code in order to not be able to reverse engineering it over Linux or not?
I have heard there are some ways over Windows to do it, but I am working on Linux.
I want to compile my code securely, as released or final version.
UPDATE
At least I want to make it hard for usual users to disassemble,
I am using GCC for C and GPP for C++, also I would be thankful if you introduce me best compiler for Python.
I want to know if there are ways to compile c, c++ and python code in order to not be able to reverse engineering it over Linux or not?
You could always obfuscate the code, but know this: A dedicated reverse engineer can not be stopped. As someone else once said on this site: You can't protect your code technologically, only legally.
I want to compile my c, c++ and python code securely... as released or final version...
Well, as far as python is concerned, you could always ship the software as an executable created by an exe packager such as py2exe or freeze. Refer to this question.
also I would be thankful if you introduce me best compiler for Python
In the Python world, you aren't talking about a compiler, rather, about a specific implementation. Most people use the reference cpython implementation. There are also alternatives such as pypy or jython,
but they are not dedicated compilers, rather, full blown virtual machines.
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
I had a look at Kivy,but the problem is it needs a virtual machine to run apps. Isn't there a way where python codes are directly converted to java bytecode which can be run by android without any virtual machine? What are the merits/demerits in terms of performance?
May be something in jython which would help?
Try SL4A for running Python code directly on your device. It requires no compiling, conversion to bytecode or virtual machines.
More information Here
Also, you can download an IDE (I've used Eclipse, like in the tutorial you will find on the site), installed a plug-in, created my source files there and then uploaded them to my phone, if you're uncomfortable with writing code on your device.
This page has full instructions on how to package a Kivy app into an APK: http://kivy.org/docs/guide/packaging-android.html
I think some one mislead you a lot or you are confused about how things work with kivy.
I'll take this opportunity to try and make things a bit more clear.
Kivy can be used to build stand alone apk, only if you had searched kivy in google play. This link shows a list of apps that mention kivy, there are a lot more apps there that use kivy and just don't mention that. There is also a partial user maintained list you can look at. You can install the apps from google play and you'd see that they are self contained and don't require you to download anything extra.
There are very easy instructions available on how to build a apk in the link mentioned by #Marcins.
Every python code passes through the python interpreter usually pre-compiled to pyc, that's how python works even Java uses a virtual machine JVM, Android's implementation uses Dalvik VM. You can learn more about the VirtualMachines used in the languages like java/python here. The python interpreter/vm consumes the code and executes it natively, it doesn't convert it to java byte code.
if you need to make something that needs more performance then you can even use cython with kivy to get more speed.
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
I want to learn python so I downloaded it from the python site and I saw 4 other kinds of pythons appear:
Python (normal)
IronPython
Jython
PyPy
Stackless Python
I can really find what the differents are between these.
Also which one is the best to start with.
Updated to include corrections from kind people in the comments section:
Of the python implementations you mention, the original and most commonly used is CPython (python on your list - which is an interpreter for python implemented in C and running as a native application) and is available for pretty much every platform under the sun. The other variants are:
IronPython: runs on the .Net common runtime (interfaces more cleanly with other .Net apps)
Jython: runs on the JVM (interfaces more cleanly with Java and other JVM apps)
PyPy: A Python interpreter which includes a just-in-time compiler which can significantly increase program execution performance. The interpreter and JIT are implemented in RPython (rather than C), a restricted subset of Python which is amenable to static analysis and type inference.
Stackless Python: An implementation of a python interpreter which doesn't rely on recursion on the native C runtime stack, and therefore allows a load of other interesting programming constructs and techniques (including lightweight threads) not available in CPython.
There are a large variety of libraries for Python (one of the major advantages of the language), the majority developed for CPython. For a number of compatibility reasons, none of the variants above currently support as many as the main implementation. So for this reason, CPython is the best place to start, and then if your future requirements fit one of the other platforms - you'll be in a good place to learn the variations from a solid grounding in the basics.
Python. All the documentation you'll find for learning the language assumes this. Then if you find a need for one of the other implementations the documentation will assume you know Python and explain the differences.
Start with Python.
The alternatives are for special use cases that apply mostly when you are integrating Python with other languages, which is a very advanced usage of the language.