Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm new to Linux and am trying to set up Python / Django on my machine! I installed Python 3.3 from the source file and it was compiled into /usr/local/bin. Then I created a symbolic link between /usr/bin/python and /usr/local/bin/python3, so that whenever I invoke python from the command line it uses the latest version.

Now I am trying to install MySQL Python and I got the following output:

apt-get install python-mysqldb

Reading package lists... Done
Building dependency tree
Reading state information... Done
python-mysqldb is already the newest version.
The following extra packages will be installed:
  apt-listchanges python-apt
Suggested packages:
  python-glade2 python-gtk2 python-apt-dbg python-vte python-apt-doc
The following packages will be upgraded:
  apt-listchanges python-apt
2 upgraded, 0 newly installed, 0 to remove and 142 not upgraded.
3 not fully installed or removed.
Need to get 0 B/394 kB of archives.
After this operation, 250 kB of additional disk space will be used.
Do you want to continue [Y/n]? Y
Traceback (most recent call last):
  File "/usr/bin/apt-listchanges", line 28, in <module>
    import apt_pkg
ImportError: No module named 'apt_pkg'

Any ideas on how to fix this? Or any tips on how to clean up this install (if this one is too broken)?

share|improve this question
3  
"I installed Python 3.3 from the source file" -- why? Not sure which OS you're on, but backports should be available and make life a lot easier. Ubuntu 12.04 PPA providing Python 3.3 is here. –  gertvdijk Dec 8 '12 at 0:38
add comment

closed as off topic by mdpc, Scott Pack, Ward, Brent Pabst, dunxd Dec 12 '12 at 15:33

Questions on Server Fault are expected to relate to professional server, networking, or related infrastructure administration within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer

up vote 1 down vote accepted

Way too many packages in Debian still rely on Python 2.x. As a result, almost everyone needs Python 2.x to be installed.

Usually, the following is done to have both Python 2.x and 3.x:

  • /usr/bin/python refers to a Python 2.x binary
  • /usr/bin/python3 refers to a Python 3.x binary

To see what is the currently installed version of Python on your machine, run:

ls -l /usr/bin/python*

(results in e.g. /usr/bin/python2.7)

To remove the symlink: rm -i /usr/bin/python

To create the symlink: ln -s /usr/bin/python2.7 /usr/bin/python

share|improve this answer
    
More specifically, Django only has experimental support for Python 3: docs.djangoproject.com/en/dev/faq/install/… –  Shane Madden Dec 8 '12 at 1:05
    
thanks so much -- that fixed it. i think it was too early for me to start using python 3.x –  user1881353 Dec 11 '12 at 1:19
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.