You are not logged in.

#1 2012-05-07 06:57:13

amatriain
Member
Registered: 2011-06-02
Posts: 50

[SOLVED] Error upgrading python-distribute

Today's upgrade throws a failure related to python-distribute:

error: failed to commit transaction (conflicting files)
python-distribute: /usr/lib/python3.2/site-packages/__pycache__/pkg_resources.cpython-32.pyc exists in filesystem
Errors occurred, no packages were upgraded.

I don't know what package installed that file. Should I do a 'pacman -Sf python-distribute' ?

Last edited by amatriain (2012-05-07 08:18:33)

Offline

#2 2012-05-07 07:10:28

headkase
Member
Registered: 2011-12-06
Posts: 1,976

Re: [SOLVED] Error upgrading python-distribute

Do:

pacman -Qo /usr/lib/python3.2/site-packages/__pycache__/pkg_resources.cpython-32.pyc

And that will tell you the package that currently owns that file.  Then you can consider whether or not to uninstall that package before trying again.

The -f, force, switch?  Go ahead if you'd love to subtly break your system thoroughly over time.

Last edited by headkase (2012-05-07 07:11:13)

Offline

#3 2012-05-07 07:14:13

amatriain
Member
Registered: 2011-06-02
Posts: 50

Re: [SOLVED] Error upgrading python-distribute

I got this:

$ pacman -Qo /usr/lib/python3.2/site-packages/__pycache__/pkg_resources.cpython-32.pyc
error: No package owns /usr/lib/python3.2/site-packages/__pycache__/pkg_resources.cpython-32.pyc

So, no package installed it. I certainly didn't copy it by hand. Yet it's there. I guess some python program created it? I don't know.

Anyone knows if it would be safe to delete it and upgrade python-distribute?

Offline

#4 2012-05-07 07:18:17

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,385
Website

Re: [SOLVED] Error upgrading python-distribute

You created it by running stuff as root...    -Sf for that package only is fine.

Offline

#5 2012-05-07 07:18:18

headkase
Member
Registered: 2011-12-06
Posts: 1,976

Re: [SOLVED] Error upgrading python-distribute

If no package owns the file then I would consider a force.  That is a .pyc file, PYthon Compiled to bytecode file, so it is possible that if you ever ran your Python interpreter as root that it went ahead and generated that file automatically while it was executing the associated .py file.

Remember, you should never force unless you have a good reason.  The learning experience here is: do you consider an un-owned file a good enough reason to force?

Offline

#6 2012-05-07 07:44:31

headkase
Member
Registered: 2011-12-06
Posts: 1,976

Re: [SOLVED] Error upgrading python-distribute

Allan says do it so I'd do it.

A bit more explanation: when you run a python script - ending with the .py extension - the Python interpreter will automatically compile that into a form that is more efficient for it to process.  This form, the .pyc file, has the same file name but instead of containing human-readable text it contains "short-hand" or bytecode.  The Python interpreter will try to put the .pyc file into the same folder that contains the .py file.  If the Python interpreter is able to write that file, it is either in a location the calling-user has rights to or the calling user is root which has rights everywhere, then it will do so.  The Python interpreter keeps track of .py and .pyc files by the time-stamp on the file.  If you modify the .py file the interpreter will see that the time-stamp for the .pyc file is different and will then try to generate a new .pyc file if so.

So, whenever you interpret a .py file with Python it will attempt to create a .pyc file.  Keeping them synchronized is handled automatically by Python.  Running Python as root will generate .pyc files where they might not otherwise be generated.  As Allan stated, that is what happened in this case.

Offline

#7 2012-05-07 08:18:00

amatriain
Member
Registered: 2011-06-02
Posts: 50

Re: [SOLVED] Error upgrading python-distribute

As suggested, I did a 'pacman -Sf python-distribute' to upgrade python-distribute, and after that did a 'pacman -Syu'. Upgrade went without a hitch. Thanks you both of you. Marking as solved.

I also learned a bit about how python works (I'm not too familiar with it), which is a definite plus.

As a side note, I think it would be desirable that in this particular case pacman went ahead with the upgrade without having to use the 'f' flag, as I guess it's safe to overwrite the .pyc file with the version that comes with the package. I'm sure it's been discussed before and there are good reasons for the current behavior, though.

Offline

#8 2012-05-07 17:38:04

knuckles
Member
Registered: 2008-01-24
Posts: 13

Re: [SOLVED] Error upgrading python-distribute

I also had this problem, so I just removed all of the conflicting pyc files. Can anyone provide an opinion on which approach (deleting the pyc's or pacman -Sf) is the better choice.

Offline

#9 2012-05-07 19:09:49

mankand007
Member
From: Chennai, India
Registered: 2012-02-26
Posts: 43
Website

Re: [SOLVED] Error upgrading python-distribute

I had this problem with Python-distribute and ranger too, and -Sf both the package solved it. Thanks for the advice!!


Custom built Openbox Arch linux 64

blog:
http://manikandan.means.it

Offline

#10 2012-05-10 05:47:09

reverland
Member
Registered: 2012-03-25
Posts: 19

Re: [SOLVED] Error upgrading python-distribute

I meet the same problem,-Sf works fine

Offline

Board footer

Powered by FluxBB