i have no way of upgrade to python 2.7 or 3.1 so i am stuck with python 2.6 on my ubuntu 10.04 machine.
will i still be able to find host that supports python 2.6?
is using python 2.6 still consider outdated or bad practice?
2.6 will be around for a long time. There are many machines that still run even 2.4, so you're fine.
Python 2.6 will probably still be around for a while, as Python 2.7 was released only a few months ago.
You can always use from __future__ import ... to make use of some of the newer features from Python 3.x
will i still be able to find host that
supports python 2.6?
Yes. No problems whatsoever.
is using python 2.6 still consider
outdated or bad practice?
No, it is not.
However:
I have no way of upgrade to python 2.7
Yes you do. You download the source code from www.python.org and install it.
What you should be careful to do in not to overwrite the system Python.
Install it either with "altinstall" (will not override the system python) or even better,
use a custom prefix. For example:
$ ./configure --prefix = /opt/python27
$ make
$ sudo make install
It is often a good idea to use a separate Python install for development, as you can do whatever you want with it including deleting it and reinstalling it without affecting the system Python.
You are NOT stuck. :)
I'm Using Ubuntu 10.04 as well I have Python 2.3.7, 2.4.6, 2.5.5, 2.6.6, 2.7.1, 3.0.1, 3.1.2 and 3.2b2+ installed. No problems. Yes, I use all of them, even though it's mostly 2.4 and 2.6.
Python3.1 is in the repositories for 10.04
$ apt-cache show python3
Package: python3
Priority: optional
Section: python
Installed-Size: 76
Maintainer: Ubuntu Developers <ubuntu-devel-discuss#lists.ubuntu.com>
Original-Maintainer: Matthias Klose <doko#debian.org>
Architecture: all
Source: python3-defaults
Version: 3.1.2-0ubuntu1
Depends: python3.1 (>= 3.1.2), python3-minimal (= 3.1.2-0ubuntu1)
Suggests: python3-doc (>= 3.1.2-0ubuntu1), python3-tk (>= 3.1.2-0ubuntu1), python3-profiler (>= 3.1.2-0ubuntu1)
Filename: pool/main/p/python3-defaults/python3_3.1.2-0ubuntu1_all.deb
Size: 11096
MD5sum: 81f3f3bf790f5d7756b76c8d92fcea86
SHA1: 32e12dc7f9500456e063f22645c1cfed76b8845c
SHA256: 0f541352ace2fcf1929a93320ffbe2f1de4e1d140bbe70a7c5a709403b73341c
Description: An interactive high-level object-oriented language (default python3 version)
Python, the high-level, interactive object oriented language,
includes an extensive class library with lots of goodies for
network programming, system administration, sounds and graphics.
.
This package is a dependency package, which depends on Debian's default
Python version (currently v3.1).
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Origin: Ubuntu
Supported: 3y
Related
I am new to python packages and libraries. I have been working on upgrading ubuntu container from 14.04 to 21.04. There has been a dependency where many applications were written on python2 library and on ubuntu 21.04, python2 is deprecated and only python3 is supported. Using few blogs, somehow I am able to install python2 and made it as default. I need to install python2 libvirt binding on ubuntu 21.04. Please help me to install the same!
Please note, due to some dependencies, python3 is not recommended for the use.
Thanks!!!
Libvirt dropped support for Python 2 over 18 months ago now.
https://gitlab.com/libvirt/libvirt-python/-/commit/b22e4f2441078aec048b9503fde2b45e78710ce1
Old versions of the libvirt-python binding are not likely to compile against currently releases of libvirt library. So you really do need to get over to using Python 3.
I was wondering if it is possible to use Cocoa (Apple's API) with Python, so being able to run any code like in this link, so NSWorkspace functions and so on, this might be a super stupid question, but I was still wondering if it was possible...
Yes.
There are Python packages, kind of wrappers around Objective-C, install them like:
$ pip install pyobjc-core
$ pip pyobjc-framework-Cocoa
$ pip pyobjc-framework-Quartz
https://pypi.org/project/pyobjc-framework-Cocoa/
MacOS by default comes with python 2.7 and pyObjC 2.5, and has done for years. If you want a newer version of either python, such as python 3, or the newest version of pyObjC, then you have to install it yourself.
The latest version of pyObjC is 5.2.
However, on a default installation of MacOS from at least Snow Leopard onward, the following should work:
python
>>> import Appkit
>>> AppKit.NSWorkspace.sharedWorkspace().runningApplications()
Catalina is stated to be the last version to contain python bundled.
In my CentOS7.2, I have the python3 command, but why I can not use pyvenv?
[root#www myProject]# pyvenv --version
-bash: pyvenv: there is no command
[root#www myProject]# python3 --version
Python 3.5.2
[root#www myProject]# which python3
/usr/bin/python3
pyvenv was deprecated in 3.6, in favor of using python3 -m venv.
You may wonder what this has to do with your Python 3.5.2, since 3.5 < 3.6. Well, if you run a Python 3.5—or even 3.6—installer from python.org, or make install from source, you will get a pyvenv command (and possibly also pyvenv3, pyvenv3.5, and/or pyvenv-3.5). But you didn't do that; you used your distro's Python 3.5.
Distros have a long tradition of breaking up large packages like Python into a core package and various "optional" packages like python3-pip or python3-curses. And not just Red Hat;1 Debian and Ubuntu also separate venv out into a python3-venv package. How they decide what's "core" and what's "optional" is a complicated process, with a lot of legacy concerns, so I don't know exactly what the reasons are, but I can speculate.
First, most linux users seem to prefer using pipenv and/or virtualenv. They have more features, they aren't stuck with Python's glacial release cycle, and you can use the same version with Python 3.4, 3.6, and even 2.7. In 2011, adding venv seemed like TOOWTDI to eliminate the incompatible competing virtual environment solutions, but what's happened instead is that they've become compatible with each other while venv has stagnated. In fact, the official Python Packaging Authority2 recommends virtualenv for installing packages and pipenv for developing applications, and the PyPA rejected a suggestion to change that in 2017.
Also, as the 3.6 docs explain, the reason pyvenv was deprecated was basically because of the confusion it causes on Linux distros that ship multiple versions of Python.
And finally: venv depends on pip. Which isn't built in. How does that work? Well, if you get a python.org binary installer, it will include pip. And if you build it from source, Python (3.4+) uses ensurepip to bootstrap pip and setuptools. But that's primarily for the convenience of Mac and Windows users, and people who build custom versions of Python; few linux distros rely on ensurepip. After all, the reason you're using an enterprisey stable distro is that you want specific, tested versions of everything, which you do by installing their python3-pip package, not by getting a kludgy pip out of ensurepip and then doing pip install --upgrade pip to get some future version they haven't tested. So, unless a distro is going to merge their pip into their python package, it doesn't make much sense to include venv.
1. CentOS 7.2 of course just copies RHEL 7.2, because that's the point of CentOS, so the question is why RHEL 7.2 made venv an optional package.
2. Just how official is PyPA? It's not entirely clear—it's under the PSF, and uses a python.org SIG, but it maintains a separate presence. But if you look at the names involved, it's largely the same people who are both Python core devs and developers for the major linux distros. So, it's not too surprising those distros pay attention to PyPA—it's the same people making the decisions in both places.
My Ubuntu uses python 3.4 as default python. Now I need to use python 2.7. The problems is it's difficult to clearly find out how to switch the default python version , and that numerous libs was installed with python 3.4- which makes python 2.7 unsupported.
Could anyone help me?
Ubuntu has something called Dead Snakes repository from where you can install any version of Python, maintained by Felix Krull.
https://launchpad.net/~fkrull/+archive/ubuntu/deadsnakes
The best practice is to
Install Python from deadsnakes PPA
Create a virtualenv for corresponding Python
virtualenv -p python2.7 my-venv
Then you use this virtualenv for further Python development and deployment
source my-venv/bin/active
Read more about Python virtual environments.
Do not change anything Python related in /usr/bin or symlinks. This breaks all your operating system packages depending on Python.
I have Python 2.6 & 3.1 installed on Leopard via mac ports with no problems. I want to install Django 1.2 via mac ports for Python 2.6, but a google search of how to do it seems to point me in the wrong direction. Can anyone point me in the right direction? Thanks again.....
Just don't do that. Install it directly from source.
Or better, use easy_install:
easy_install django
Or even better, use pip (and add virtualenv as a bonus (and virtualenvwrapper for more fun!)):
pip install django
What is wrong with this package?
$ port info py26-django
py26-django #1.2.1 (python, www)
Variants: bash_completion, universal
Description: Django is a high-level Python Web framework that
encourages rapid development and clean, pragmatic design.
Homepage: http://www.djangoproject.com
Library Dependencies: python26, py26-distribute
Platforms: darwin
License: unknown
Maintainers: arthurk#macports.org
Just "throw" the django tarball within the site-packages (dist-packages in py2.6+) and you are done. What for do you need macports etc, with a pure python library?