# upgrade python 2.6 to 2.7 with all site packages etc



## pinglin (Oct 15, 2012)

Hello,

Please help upgrade python2.6 to python2.7.

Tried to use steps given in this thread 
http://forums.freebsd.org/showthread.php?t=1390

FreeBSD 7.2-RELEASE-p2
Running 'python' shows

```
Python 2.6.8 (unknown, Oct  7 2012, 20:27:55)
>>>
```
The *pkg_info -E python\** gives

```
python26-2.6.8
python27-2.7.3
```

From http://www.freshports.org/lang/python/

If using portupgrade:

```
# portupgrade -o lang/python27 lang/python26
  # portupgrade -R python
  # cd /usr/ports/lang/python && make upgrade-site-packages
```
When I run 
`$ sudo portupgrade -o lang/python27 lang/python26`

```
** Detected a package name change: python26 (lang/python26) -> 'python27' (lang/python27)
--->  Upgrading 'python26-2.6.8' to 'python27-2.7.3' (lang/python27)
--->  Building '/usr/ports/lang/python27'
===>  Cleaning for python27-2.7.3
===>  License check disabled, port has not defined LICENSE
===>  Found saved configuration for python27-2.7.3
===>  Extracting for python27-2.7.3
=> SHA256 Checksum OK for python/Python-2.7.3.tgz.
===>  Patching for python27-2.7.3
..... all goes fine until these errors

pkg_delete: unable to completely remove directory '/usr/local/lib/python2.6/site-packages'
pkg_delete: unable to completely remove directory '/usr/local/lib/python2.6'
pkg_delete: unable to completely remove directory '/usr/local/include/python2.6'
pkg_delete: couldn't entirely delete package (perhaps the packing list is
incorrectly specified?)
[Updating the pkgdb <format:bdb_btree> in /var/db/pkg ... - 446 packages found (-1 +0) (...) done]
--->  Installing the new version via the port
===>  Installing for python27-2.7.3
/bin/cat /data/usr/ports/lang/python27/pkg-plist | /usr/bin/awk '{ print $0; }  /LIBDIR.*\.py$/ &&  !/\/bad|tests\/data/  { print $0 "o"; print $0 "c"; }'      > /data/usr/ports/lang/python27/work/PLIST
([ -f /data/usr/ports/lang/python27/work/Python-2.7.3/portbld.static/.without_own_sha ] &&  /usr/bin/grep -v 'lib-dynload/_sha' /data/usr/ports/lang/python27/work/PLIST > /data/usr/ports/lang/python27/work/PLIST.tmp &&  /bin/cat /data/usr/ports/lang/python27/work/PLIST.tmp > /data/usr/ports/lang/python27/work/PLIST) || true
===>   Generating temporary packing list
===>  Checking if lang/python27 already installed
===>   python27-2.7.3 is already installed
      You may wish to ``make deinstall'' and install this port again
      by ``make reinstall'' to upgrade it properly.
      If you really wish to overwrite the old port of lang/python27
      without deleting it first, set the variable "FORCE_PKG_REGISTER"
      in your environment or the "make install" command line.
*** Error code 1

Stop in /data/usr/ports/lang/python27.
*** Error code 1

Stop in /data/usr/ports/lang/python27.
*** Error code 1

Stop in /data/usr/ports/lang/python27.
** Command failed [exit code 1]: /usr/bin/script -qa /tmp/portupgrade20121015-2178-q16vrg-0 env UPGRADE_TOOL=portupgrade UPGRADE_PORT=python26-2.6.8 UPGRADE_PORT_VER=2.6.8 make reinstall
--->  Restoring the old version
```
I did 
lang/python27: *make deinstall* and *make reinstall*. 
Also set python27 as default in /etc/make.conf.
Now '*python*' gives

```
Python 2.7.3 (default, Oct 15 2012, 07:35:54) 
[GCC 4.2.1 20070719  [FreeBSD]] on freebsd7
Type "help", "copyright", "credits" or "license" for more information.
```
But I don't have site packages from python26. 
So, how can I get them on python27?
I need files from /usr/local/lib/python2.6/site-packages/ to be in /usr/local/lib/python2.7/site-packages/.
`# make upgrade-site-packages` does not help.
I don't think it is safe just copy them...
Please help.


----------



## SirDice (Oct 15, 2012)

pinglin said:
			
		

> FreeBSD 7.2-RELEASE-p2


FreeBSD 7.2 went End-of-Life in June 2010.


----------



## pinglin (Oct 15, 2012)

I have to stay with this version. It is mandatory to use freebsd 7.2


----------



## SirDice (Oct 15, 2012)

pinglin said:
			
		

> I have to stay with this version. It is mandatory to use FreeBSD 7.2



Metin-2?


----------



## pinglin (Oct 15, 2012)

Don't know what 'metin-2' is, google says it is some game . No, it is mandatory due to project I work on.


----------



## SirDice (Oct 15, 2012)

Upgrade to at least 7.4. There's absolutely no reason to keep running an unsupported version. There have been various security issues, all of which are NOT patched (and never will be patched) on this version.


----------



## pinglin (Oct 15, 2012)

Ok. Deinstalled python2.7 and successfully upgraded with portupgrade -o lang/python27 lang/python26. 
Now make upgrade-site-packages fails

```
** Port directory not found: python/py-DataParser
** Port marked as IGNORE: databases/py-MySQLdb:
	cannot install: unknown MySQL version: 40
** Port marked as IGNORE: databases/py-psycopg2:
	cannot install: unknown PostgreSQL version: 82
** There are errors in a meta info for py26-pysqlite-2.3.5
** Run 'pkgdb -F' to interactively fix them.
*** Error code 1
```

*pkgdb -F*

```
Deinstall mysql-client-4.0.27 ? [no] yes
--->  Deinstalling 'mysql-client-4.0.27'
pkg_delete: package 'mysql-client-4.0.27' is required by these other packages
and may not be deinstalled:
mysql-server-4.0.27
py26-MySQLdb-1.2.2
py26-sqlalchemy-0.5.2
** Listing the failed packages (-:ignored / *:skipped / !:failed)
	! mysql-client-4.0.27	(pkg_delete failed)
Command failed [exit code 1]: /usr/local/sbin/pkg_deinstall mysql-client-4.0.27
```


----------



## pinglin (Oct 15, 2012)

Thank you, SirDice. Done. This thread can be closed.


----------

