Python - what is difference in os.popen and subprocess.Popen? - process

Python - what is difference in os.popen and subprocess.Popen?

The os process functionality is considered obsolete. The subprocess module was introduced in Python 2.4 as a unified, more powerful replacement for several older modules and functions related to subprocesses. They are listed here:
os.system
os.spawn*
os.popen*
popen2.*
commands.*
os.popen was deprecated in Python 2.6 (but, interestingly, it is not deprecated in Python 3, where it is implemented in terms of subprocess.Popen). There is a paragraph in the documentation on how to replace it with subprocess.Popen.

Related

Python - program written in Python 3.5.2 also executable on higher python versions?

I've written a program on the python version 3.5.2, because i need a 64 bit version of python for my tensorflow-gpu library.
Its also possible to use the normal tensorflow library, which doese'nt require a 64 bit python, but in my case i wanted to use my gpu.
My question is: If some users have a higher version installed (of python) and use the normal tensorflow library, will they still be able to execute it?
Fabian
It all depends on what code you used, and if the syntax was changed in later versions. For example, if your version of Python uses print "Hello World!" and the user's version is print("Hello World"), then you would have to change it to the later versions specification.

What is the numpy pypi package naming convention

Trying to determine which numpy package is compatible with my python environment. My server has no internet access, so I need to download and install the package locally.
I know the cp27 refers to Python 2.7, but what is the difference between these two packages:
numpy-1.12.0rc1-cp27-cp27m-manylinux1_x86_64.whl
numpy-1.12.0rc1-cp27-cp27mu-manylinux1_x86_64.whl
The differing part is an ABI tag.
mu indicates --enable-unicode=ucs4
m on its own is --enable-unicode=ucs2
See UCS-2 vs UCS-4 builds; to determine which you need for your current installation, see How to find out if Python is compiled with UCS-2 or UCS-4?

Which python version is recommended with odoo?

What is the recommended version of python to use with openerp/odoo? Is it 2.7 or 3
All these days I was using 2.7 if I choose ver 3 will it cause any problems?
Odoo work with Python 2.7 up to version 10.0
For version 11.0, Python must be on version 3.5 or higher
I won't work yet with python 3. The best python version to have is the highest 2.7.* (at least 2.7.3).
You can see the major dependencies and python version in the installing tutorial:
Installing Odoo (version 8.0)
Installing Odoo (version 9.0)
On my operating system, python 3 is the default so to start an instance without using a bundle (in my case I clone the github repository), I use this command:
python2 ~/path-to-my-odoo-git/odoo.py -d odoo-test
As for when odoo will work with python 3, there is a number of needed python package dependencies not already ported to python 3. Even if they were already all ported, Odoo itself would take some efforts (without talking about all the ecosystem of custom addons which would get unusable untill ported).
So I guess it will not be available before 1 year and most probably not available before 2 or 3 years.

installing virtualenvwrapper causes untested argparse to be installed

I have installed virtualenvwrapper in a 3.5.0b1 virtualenv, called setupenv, to be able to generate new python 3.5 test environments easily.
Looking over the list of installed packages, I did see argparse version 1.3.0 installed. This (latest) version of argparse has not been tested with 3.5.
Is this dangerous?
As far as I know 3.2+ comes with its own argparse. Could this install break other packages relying on argparse? Why is this installed at all?
This is probably not dangerous. If you run:
python3.5 -c "import argparse; print(argparse.__file__)"
, you can see that the arparse.py installed with the interpreter takes precedence over the superfluously installed argparse package.
A bit of digging (or using the pipdeptree package) will show you that stevedore is dependent on argparse. This is just sloppy programming (or disregard of possible bandwidth issues).
In a package's setup.py you can easily test if you are running python < 2.7 or 3.0 <= python < 3.2 and only install argparse for those cases.
I would just de-install argparse from your setupenv virtualenv (pip uninstall argparse -y), virtualenvwrapper is not affected by the removal in my experience.
This is actually a bug in stevedore, it uses the pbr package and that supports specification of the python version using environment markers
but stevedore is not using that. The irony is that the example for this in pbr is with argparse, by specifying in the requirements.txt:
argparse; python=='2.6'
A bug report against stevedore was filed, but although the fix was trivial, it was not implemented for several releases. Finally the issue was
set to won't fix, probably because dropped support for 2.6 removed the
need for argparse altogether.

installing matplotlib on ubuntu?

I have:
Ubuntu 8.04
python 2.5.2 installed on this Ubuntu
matplotlib 0.92.0 installed
I want to upgrade to (atleast) matplotlib 0.99
so that I can do 3d plotting.
The synaptic package (also the command line apt-get)
tells me that whatever I have is the latest matplotlib (which is not true).
How can I install matplotlib 0.99 or matplotlib 1.0.1 ?
You have the latest available package version for your operating system. Given that Ubuntu is at version 11 now and you are using 8.04, the version difference in the matplotlib package might not come as very surprising.
As for installing the newest version, I'd suggest reading:
http://matplotlib.sourceforge.net/faq/installing_faq.html
...if all fails, you can always install from source.
Note that support for Desktop versions of 8.04 LTS is due to expire shortly -- if this is a desktop machine, perhaps the easiest answer is to upgrade to 10.04 LTS, 10.10, or the very-soon-upcoming 11.04 release (or whatever they'll call the next release). Maybe not "the easiest answer", but an answer that includes security updates for Mozilla, Adobe Flash, the Kernel, and so forth.
Many newer versions of packages are supported via the Ubuntu Backports facility, but I didn't spot python-matplotlib in the list of available packages. Perhaps they would provide it if you asked nicely, perhaps it would be too much work.
You can always try installing newer versions from newer releases, but newer versions of python and libraries might introduce worse problems. (But probably will work fine.) See the apt_preferences(5) manpage for details on how to configure multiple APT sources and select some specific packages from a newer distribution (pinning), and rely on the older distribution for all the other packages.
Jim's answer of building the version you need from source is probably your best second option, if installing a newer version of the distribution is too daunting / otherwise impossible at this point.