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

AttributeError: module 'pelican_youtube' has no attribute 'register' #645

Open
Nagasaki45 opened this issue Jan 13, 2016 · 4 comments
Open

Comments

@Nagasaki45
Copy link

I'm unable to add the pelican_youtube plugin to pelicanconf.py. I'm getting the following traceback when trying to build the site:

Traceback (most recent call last):
  File "/home/nagasaki45/miniconda3/envs/pelican-check/bin/pelican", line 11, in <module>
    sys.exit(main())
  File "/home/nagasaki45/miniconda3/envs/pelican-check/lib/python3.5/site-packages/pelican/__init__.py", line 386, in main
    pelican, settings = get_instance(args)
  File "/home/nagasaki45/miniconda3/envs/pelican-check/lib/python3.5/site-packages/pelican/__init__.py", line 380, in get_instance
    return cls(settings), settings
  File "/home/nagasaki45/miniconda3/envs/pelican-check/lib/python3.5/site-packages/pelican/__init__.py", line 57, in __init__
    self.init_plugins()
  File "/home/nagasaki45/miniconda3/envs/pelican-check/lib/python3.5/site-packages/pelican/__init__.py", line 84, in init_plugins
    plugin.register()
AttributeError: module 'pelican_youtube' has no attribute 'register'

Steps to reproduce:

  1. Create a new pelican project with pelican-quickstart.
  2. Clone the pelican-plugins repo (recursively) to ./pelican-plugins.
  3. Add the following lines to pelicanconf.py:
PLUGIN_PATHS = ['pelican-plugins']
PLUGINS = ['pelican_youtube']
  1. Build the site using pelican content -o output -s pelicanconf.py.
  2. Notice the failure above.

The issue is caused by the pelican_youtube folder not being a valid python module (/package) with register attribute.

@Nagasaki45
Copy link
Author

I found a possible fix, which is quite ugly in my opinion. I created a pelican_youtube.py module in the pelican-plugins dir with the following content:

import sys
import os

PLUGINS_DIR = os.path.dirname(__file__)
sys.path.append(os.path.join(PLUGINS_DIR, 'pelican_youtube', 'pelican_youtube'))

from youtube import register

@justinmayer
Copy link
Member

@Nagasaki45 / @lincolnfrias: Would you consider submitting a PR to address the issue(s) discussed here?

@Nagasaki45
Copy link
Author

@justinmayer, do you have an idea that is less hacky than the one I suggested above? If not I will send a PR with the hack.

@scheunemann
Copy link

The issue is that pelican_youtube follows the structure of python package. I think it should be considered to search in <plugin_name>/<plugin_name> if there is not init in the first level, for now, it can be used with:

PLUGIN_PATHS = ['<path/to/pelican-plugins>/pelican_youtube']
PLUGINS = ['pelican_youtube']

or with installing it via pip install pelican-youtube

PLUGINS = ['pelican_youtube']

I am facing a similar issue and therefore haven't pushed my plugin to the pelican-plugins repo.

JulienPalard added a commit to AFPy/python-nantes that referenced this issue Dec 20, 2019
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