Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Weirdest problem in terminal: can't run emerge, equery, etc
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Off the Wall
View previous topic :: View next topic  
Author Message
cgits
n00b
n00b


Joined: 15 Jul 2005
Posts: 65
Location: Europe

PostPosted: Sun Apr 19, 2015 10:51 am    Post subject: Weirdest problem in terminal: can't run emerge, equery, etc Reply with quote

I recently installed livestreamer, a "CLI tool that pipes video streams from services like twitch.tv into a video player" not from portage because I needed the newest version, but with
Code:
# pip install livestreamer
(as root)

Now I can't run the commands emerge or pip or equery, and possibly some more commands. Apparently, every time I give such a command, the system thinks I gave livestreamer as the first word (!?)

Code:
$ pip uninstall livestreamer
error: No plugin can handle URL: uninstall

$ sudo pip uninstall livestreamer
livestreamer is not supposed to be run as root. If you really must you can do it by passing --yes-run-as-root.

$ sudo emerge <something>
livestreamer is not supposed to be run as root. If you really must you can do it by passing --yes-run-as-root.

$ equery f pip
error: No plugin can handle URL: f

$ sudo equery f pip
livestreamer is not supposed to be run as root. If you really must you can do it by passing --yes-run-as-root.

$ eselect python list
Available Python interpreters:
  [1]   python2.7
  [2]   python3.3 *
  [3]   python3.4


I have used all three pythons on my system and it's always the same. I used the bash and sh shells, both terminal and console out of X Server. I rebooted. No idea what to do next.

PS: I just noticed that all three affected programs are symlinks to the same file ( ../lib/python-exec/python-exec2 )
Code:
user@pc /usr/bin $ ls -l /usr/bin/emerge
lrwxrwxrwx 1 root root 31 Dec  7 04:24 /usr/bin/emerge -> ../lib/python-exec/python-exec2
user@pc /usr/bin $ ls -l pip
lrwxrwxrwx 1 root root 31 Apr 17 14:27 pip -> ../lib/python-exec/python-exec2
user@pc /usr/bin $ ls -l equery
lrwxrwxrwx 1 root root 31 Dec 12 10:52 equery -> ../lib/python-exec/python-exec2
Back to top
View user's profile Send private message
SirRobin2318
Apprentice
Apprentice


Joined: 24 Apr 2004
Posts: 231
Location: Strasbourg, france.

PostPosted: Sun Apr 19, 2015 1:12 pm    Post subject: Reply with quote

First let's see if we can salvage this without being brutes:

Does this work:
Code:
/usr/lib/python-exec/python3.3/emerge -1a dev-lang/python:2.7 dev-lang/python:3.3 dev-lang/python:3.4

If that works, see if you can run python-updater.
If not:
Could you pastebin the output of env?
Could you try su - root and see if portage works?
Could you pastebin 'cat /usr/lib/python-exec/python-exec2'?

If all fails, you might have to reinstall portage manually: https://wiki.gentoo.org/wiki/Complete_Handbook/Putting_the_minimal_environment_in_place
If even that fails, you could try to extract a stage3 tarball to overwrite the core of your system, but only do this as a last resort, it'll probably break things.


Last edited by SirRobin2318 on Sun Apr 19, 2015 1:19 pm; edited 1 time in total
Back to top
View user's profile Send private message
SirRobin2318
Apprentice
Apprentice


Joined: 24 Apr 2004
Posts: 231
Location: Strasbourg, france.

PostPosted: Sun Apr 19, 2015 1:18 pm    Post subject: Reply with quote

Also, next time, install extra software as a user, in a ~/local or something. If you want multiple users to use the same software, install it in /opt/local instead. Something like this should have worked:
PYTHONPATH=/opt/local pip install stuff
Back to top
View user's profile Send private message
cgits
n00b
n00b


Joined: 15 Jul 2005
Posts: 65
Location: Europe

PostPosted: Sun Apr 19, 2015 7:23 pm    Post subject: Reply with quote

SirRobin2318 wrote:
...
If that works, see if you can run python-updater.
If not:
Could you pastebin the output of env?
Could you try su - root and see if portage works?
Could you pastebin 'cat /usr/lib/python-exec/python-exec2'?

If all fails, you might have to reinstall portage manually: https://wiki.gentoo.org/wiki/Complete_Handbook/Putting_the_minimal_environment_in_place
If even that fails, you could try to extract a stage3 tarball to overwrite the core of your system, but only do this as a last resort, it'll probably break things.


Thank you very much for your answer. With your first suggestion I managed to run emerge and all other programs giving the full path (/usr/lib/python-exec/python3.3/emerge) instead of just emerge. But then python-updater does not run, I think because it calls portageq, which is also in the same directory. By the way, everything that is in there cannot be called directly (archive-conf dispatch-conf eclean egencache emirrordist epkginfo f2py gjl livestreamer pildriver.py pilprint.py quickpkg revdep-rebuild.py chardetect easy_install eclean-dist emaint enalyze equery fixpackages glsa-check mirrorselect pilfile.py portageq regenworld depend-java-query ebuild eclean-pkg emerge env-update eshowkw gdbus-codegen java-config-2 pilconvert.py pilfont.py py.test repoman)

Code:
sudo python-updater
usage: portageq [OPTIONS] [URL] [STREAM]
portageq: error: unrecognized arguments: =dev-lang/python-2*
usage: portageq [OPTIONS] [URL] [STREAM]
portageq: error: unrecognized arguments: =dev-lang/python-3*
 * Python 2 and Python 3 not installed


Portage does not work when I am root, I had already tried that but I did not mention it explicitly.

The next part is very funny, python-exec2 looks completely screwed up by livestreamer.
Code:
$> cat /usr/lib/python-exec/python-exec2
#!/usr/bin/python2.7
# EASY-INSTALL-ENTRY-SCRIPT: 'livestreamer==1.12.1','console_scripts','livestreamer'
__requires__ = 'livestreamer==1.12.1'
import sys
from pkg_resources import load_entry_point

if __name__ == '__main__':
    sys.exit(
        load_entry_point('livestreamer==1.12.1', 'console_scripts', 'livestreamer')()
    )


Could you post yours so maybe I can copy it? There is also another file in the same directory, python-exec2-c but its modification date is older than the livestreamer install, so I guess it is not affected.
Back to top
View user's profile Send private message
energyman76b
Advocate
Advocate


Joined: 26 Mar 2003
Posts: 2034
Location: Germany

PostPosted: Sun Apr 19, 2015 7:41 pm    Post subject: Reply with quote

#!/usr/lib/python-exec/python-exec2-c
# vim:fileencoding=utf-8:ft=python
# (c) 2012 MichaŠGórny
# Released under the terms of the 2-clause BSD license.
#
# This is not the script you are looking for. This is just a wrapper.
# The actual scripts of this application were installed with -python*,
# -pypy* or -jython* suffixes. You are most likely looking for one
# of those.

from __future__ import with_statement
import os, os.path, sys

try:
from epython import EPYTHON
except ImportError:
EPYTHON = os.path.basename(sys.executable)
if '' and EPYTHON.endswith(''):
EPYTHON = EPYTHON[:-len('')]

# In the loop:
# sys.argv[0] keeps the 'bare' name
# __file__ keeps the 'full' name

while True:
__file__ = os.path.join('/usr/lib/python-exec', EPYTHON,
os.path.basename(sys.argv[0]))

try:
kwargs = {}
if sys.version_info[0] >= 3:
import tokenize

# need to provide encoding
with open(__file__, 'rb') as f:
kwargs['encoding'] = tokenize.detect_encoding(f.readline)[0]

with open(__file__, 'r', **kwargs) as f:
data = f.read()
except IOError:
# follow symlinks (if supported)
try:
sys.argv[0] = os.path.join(os.path.dirname(sys.argv[0]),
os.readlink(sys.argv[0]))
except (OSError, AttributeError):
# no more symlinks? then it's time to fail.
sys.stderr.write('This Python implementation (%s) is not supported by the script.\n'
% EPYTHON)
sys.exit(127)
else:
break

sys.argv[0] = __file__
exec(data)
_________________
Study finds stunning lack of racial, gender, and economic diversity among middle-class white males
Back to top
View user's profile Send private message
energyman76b
Advocate
Advocate


Joined: 26 Mar 2003
Posts: 2034
Location: Germany

PostPosted: Sun Apr 19, 2015 7:43 pm    Post subject: Reply with quote

I hope you have learnt your lesson and never again use crap like pip. And especially crap like pip as root.
_________________
Study finds stunning lack of racial, gender, and economic diversity among middle-class white males
Back to top
View user's profile Send private message
cgits
n00b
n00b


Joined: 15 Jul 2005
Posts: 65
Location: Europe

PostPosted: Sun Apr 19, 2015 8:03 pm    Post subject: Reply with quote

Thank you energyman76b, everything seems to be working now.

I had not heard that pip was crap before, but yes, I will never do this again.
Back to top
View user's profile Send private message
energyman76b
Advocate
Advocate


Joined: 26 Mar 2003
Posts: 2034
Location: Germany

PostPosted: Sun Apr 19, 2015 8:15 pm    Post subject: Reply with quote

cgits wrote:
Thank you energyman76b, everything seems to be working now.

I had not heard that pip was crap before, but yes, I will never do this again.


everything that takes a shit into /usr instead of /usr/local or /opt and is not the systems software manager, is crap. It is really simple.

I didn't know pip. But it dumped its garbage just into /usr/lib where it has no business which disqualifies it as a sensible tool anybody should be using.
_________________
Study finds stunning lack of racial, gender, and economic diversity among middle-class white males
Back to top
View user's profile Send private message
SirRobin2318
Apprentice
Apprentice


Joined: 24 Apr 2004
Posts: 231
Location: Strasbourg, france.

PostPosted: Sun Apr 19, 2015 9:52 pm    Post subject: Reply with quote

pip probably isn't crap, it's just not meant to be run as root. If I were you I'd reinstall everything python related, maybe pip squashed other things:
Code:
emerge -a1 `qlist -C -I dev-python/\*` dev-lang/python-exec
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Off the Wall All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum