Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The program doesn't start (error message) #760

Closed
ghost opened this issue Jan 17, 2018 · 14 comments
Closed

The program doesn't start (error message) #760

ghost opened this issue Jan 17, 2018 · 14 comments

Comments

@ghost
Copy link

ghost commented Jan 17, 2018

[~]: sudo pip3 install mps-youtube
[sudo] password for root:
Collecting mps-youtube
  Downloading mps_youtube-0.2.7.1-py3-none-any.whl (74kB)
    100% |████████████████████████████████| 81kB 1.1MB/s
Collecting pafy!=0.4.0,!=0.4.1,!=0.4.2,>=0.3.82 (from mps-youtube)
  Downloading pafy-0.5.3.1.tar.gz
Installing collected packages: pafy, mps-youtube
  Running setup.py install for pafy ... done
Successfully installed mps-youtube-0.2.7.1 pafy-0.5.3.1
[~]: mpsyt
Traceback (most recent call last):
  File "/usr/bin/mpsyt", line 7, in <module>
    from mps_youtube import main
ImportError: cannot import name 'main'

openSUSE Leap 42.3

@tommysolsen
Copy link
Member

tommysolsen commented Jan 17, 2018

If python -v returns version 2.x, then you might need to find the executable script for mpsyt using whereis mpsyt, open that file and change the first line to point to python3 instead of python

@hrnr
Copy link
Member

hrnr commented Jan 17, 2018

The script should use python3 by default

https://github.com/mps-youtube/mps-youtube/blob/develop/mpsyt

@ghost
Copy link
Author

ghost commented Jan 17, 2018

[~]: python -V
Python 2.7.13
[~]: python3 -V
Python 3.4.6
[~]: cat /usr/bin/mpsyt
#!/usr/bin/python3

# -*- coding: utf-8 -*-
import re
import sys

from mps_youtube import main

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
    sys.exit(main.main())

It seems everything is as it has to be but still the program throws this error.

@ghost
Copy link
Author

ghost commented Jan 17, 2018

@hrnr Considering the pasted code, do I need to change anything? Or does the code here (on github) need an update?

@hrnr
Copy link
Member

hrnr commented Jan 17, 2018

No, as long as your python3 is at /usr/bin/python3 (which it seems to be, because python is executing) the two shebangs are the same.

There is clearly some installation problem. You may want to try to install latest development version.

https://github.com/mps-youtube/mps-youtube/wiki/Troubleshooting#how-to-install-the-development-version

@ghost
Copy link
Author

ghost commented Jan 17, 2018

Tried, still doesn't work:

[~]: sudo pip3 install youtube_dl
Collecting youtube_dl
  Downloading youtube_dl-2018.1.14-py2.py3-none-any.whl (1.7MB)
    100% |████████████████████████████████| 1.7MB 739kB/s
Installing collected packages: youtube-dl
Successfully installed youtube-dl-2018.1.14
[~]: sudo pip3 install --upgrade https://github.com/mps-youtube/pafy/archive/develop.zip https://github.com/mps-youtube/mps-youtube/archive/develop.zip
Collecting https://github.com/mps-youtube/pafy/archive/develop.zip
  Downloading https://github.com/mps-youtube/pafy/archive/develop.zip (68kB)
    100% |████████████████████████████████| 71kB 288kB/s
Collecting https://github.com/mps-youtube/mps-youtube/archive/develop.zip
  Downloading https://github.com/mps-youtube/mps-youtube/archive/develop.zip
     - 133kB 861kB/s
Installing collected packages: pafy, mps-youtube
  Found existing installation: pafy 0.5.3.1
    Uninstalling pafy-0.5.3.1:
      Successfully uninstalled pafy-0.5.3.1
  Running setup.py install for pafy ... done
  Running setup.py install for mps-youtube ... done
Successfully installed mps-youtube-0.2.7.1 pafy-0.5.3.1
[~]: cat /usr/bin/mpsyt
cat: /usr/bin/mpsyt: Permission denied
[~]: l /usr/bin/mpsyt
-rwx------ 1 root root 316 Jan 17 17:50 /usr/bin/mpsyt*
[~]: sudo chmod 755 /usr/bin/mpsyt
[~]: l /usr/bin/mpsyt
-rwxr-xr-x 1 root root 316 Jan 17 17:50 /usr/bin/mpsyt*
[~]: mpsyt
Traceback (most recent call last):
  File "/usr/bin/mpsyt", line 9, in <module>
    load_entry_point('mps-youtube==0.2.7.1', 'console_scripts', 'mpsyt')()
  File "/usr/lib/python3.4/site-packages/pkg_resources/__init__.py", line 558, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python3.4/site-packages/pkg_resources/__init__.py", line 2681, in load_entry_point
    raise ImportError("Entry point %r not found" % ((group, name),))
ImportError: Entry point ('console_scripts', 'mpsyt') not found
[~]: cat /usr/bin/mpsyt
#!/usr/bin/python3
# EASY-INSTALL-ENTRY-SCRIPT: 'mps-youtube==0.2.7.1','console_scripts','mpsyt'
__requires__ = 'mps-youtube==0.2.7.1'
import sys
from pkg_resources import load_entry_point

if __name__ == '__main__':
    sys.exit(
        load_entry_point('mps-youtube==0.2.7.1', 'console_scripts', 'mpsyt')()
    )

@vn-ki
Copy link
Member

vn-ki commented Jan 18, 2018

Running pip in sudo is not recommended and you should not randomly change permissions of system files. Can you try these steps?

git clone https://github.com/mps-youtube/mps-youtube.git
cd mps-youtube
./mpsyt

@hrnr
Copy link
Member

hrnr commented Jan 18, 2018

The problem is that development branch is not longer installable though pip, because it is failing version check. Maybe this something that should be fixed @ids1024? Or should we fix the docs?

Try cloning and running ./mpsyt as @vn-ki advised, you should have all the dependencies already from previous attempts (don't uninstall).

@ghost
Copy link
Author

ghost commented Jan 18, 2018

Running pip in sudo is not recommended and you should not randomly change permissions of system files.

Then the README.rst should not recommend it :) I any case it is not possible to use it without sudo. Also I am not 'randomly' changing permissions but very specifically.

Can you try these steps?

[/tmp/download]: git clone https://github.com/mps-youtube/mps-youtube.git
Cloning into 'mps-youtube'...
remote: Counting objects: 6637, done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 6637 (delta 2), reused 6 (delta 1), pack-reused 6626
Receiving objects: 100% (6637/6637), 1.81 MiB | 2.14 MiB/s, done.
Resolving deltas: 100% (4480/4480), done.
[/tmp/download]: cd mps-youtube
[/tmp/download/mps-youtube]: ./mpsyt
Traceback (most recent call last):
  File "./mpsyt", line 2, in <module>
    import mps_youtube.main
  File "/tmp/download/mps-youtube/mps_youtube/__init__.py", line 8, in <module>
    init.init()
  File "/tmp/download/mps-youtube/mps_youtube/init.py", line 94, in init
    pafy.set_api_key(config.API_KEY.get)
AttributeError: 'module' object has no attribute 'set_api_key'
[/tmp/download/mps-youtube]:

you should have all the dependencies already from previous attempts (don't uninstall).

Too late for this. I already uninstalled everything yesterday because I don't like to keep non-functional software on the machine. If you have any other ideas considering the latest paste too, please let me know so I can try again.

@vn-ki
Copy link
Member

vn-ki commented Jan 18, 2018

I any case it is not possible to use it without sudo.

Not true. Check the top answer on this stackoverflow question to get a better insight.

AttributeError: 'module' object has no attribute 'set_api_key'

Do you have pafy installed? If not, install pafy and youtube-dl and try again.

If it still does not work, try these.

cd ~
pyvenv test
source test/bin/activate
pip3 install youtube_dl pafy
git clone https://github.com/mps-youtube/mps-youtube.git
cd mps-youtube
python3 mpsyt

@ghost
Copy link
Author

ghost commented Jan 18, 2018

I checked the stackoverflow question however a simple test proves that I cannot run pip or pip3 without being root:

[~]: pip
Traceback (most recent call last):
  File "/usr/bin/pip", line 7, in <module>
    from pip import main
ImportError: cannot import name 'main'
[~]: pip3
Traceback (most recent call last):
  File "/usr/bin/pip3", line 7, in <module>
    from pip import main
ImportError: cannot import name 'main'

FWIW both files have 755 permissions. I have never made any special tuning of all this. This is simply Python coming from openSUSE's official repos. If you think there is something wrong that should be reported to openSUSE please give me the details and I will do it.

Also if you insist that the SO answer is a valid one, i.e. that this is true:

If there is any tutorial out there which says you should do sudo pip then please file a bug against this package. The author is dis-educating Python community, as time has proven sudo pip to be a broken practice.

then you should probably fix the documentation here.

I have pafy (0.5.3.1) and youtube-dl (2018.1.18) installed, so I tried again:

[~]: cd /tmp/download/
[/tmp/download]: rm -rf *
[/tmp/download]: git clone https://github.com/mps-youtube/mps-youtube.git
Cloning into 'mps-youtube'...
remote: Counting objects: 6637, done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 6637 (delta 2), reused 6 (delta 1), pack-reused 6626
Receiving objects: 100% (6637/6637), 1.81 MiB | 2.44 MiB/s, done.
Resolving deltas: 100% (4480/4480), done.
[/tmp/download]: cd mps-youtube
[/tmp/download/mps-youtube]: ./mpsyt
Traceback (most recent call last):
  File "./mpsyt", line 2, in <module>
    import mps_youtube.main
  File "/tmp/download/mps-youtube/mps_youtube/__init__.py", line 8, in <module>
    init.init()
  File "/tmp/download/mps-youtube/mps_youtube/init.py", line 94, in init
    pafy.set_api_key(config.API_KEY.get)
AttributeError: 'module' object has no attribute 'set_api_key'

If it still does not work, try these.

That worked! I was able to start the program (but didn't know how to use it yet, so I simply typed quit)

Could you please explain shortly:

  1. What did I just do?
  2. Was it just for the purpose of testing?
  3. After all that - how should install and use the program in a non-test environment but the way it is supposed to work.

Thanks.

@vn-ki
Copy link
Member

vn-ki commented Jan 19, 2018

I cannot run pip or pip3 without being root

That is very weird behavior. I feel there is something terribly wrong with your permissions. The fact that you couldn't do cat /usr/bin/mpsyt supports this theory. But this issue-tracker thread is not the place to find a fix for that issue.

What did I just do?

You setup a python virtual environment. Your pip installations will go into ~/.local/bin folder instead of /usr/bin (and a lot of other changes too).

Was it just for the purpose of testing?

No. You can use it until you fix your permissions problem. The only real problem is that you have to execute bin/activate every-time you have to use mpsyt.

After all that - how should install and use the program in a non-test environment but the way it is supposed to work.

Ask on stackoverflow how to fix your permissions problem. If you don't mind using mpsyt in a virtual env look into virtualenvwrapper.

@ghost
Copy link
Author

ghost commented Jan 24, 2018

The following solved the issue:

su -
pip3 uninstall mps-youtube youtube-dl pafy
exit

pip3 install --user mps-youtube youtube-dl

After uninstalling pafy I am also able to install again the 3 packages as root and run mpsyt as normal user without the errors. Something weird may have happened to pafy in the past.

@vn-ki
Copy link
Member

vn-ki commented Jan 24, 2018

The following solved the issue:

Cheers. Please close the ticket since your issue is solved.

@ghost ghost closed this as completed Jan 24, 2018
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants