#4031 ImportError: No module named pagure.lib
Closed: Fixed 5 years ago Opened 5 years ago by ark74.

After overcomming https://pagure.io/pagure/issue/4030 now I'm looking at a new error whenever I add a comment when submitting a comment on a issue, when pressing the Comment button it freezes.
Just by manually leaving the page it can be used again.

trisquel 8 / buntu 16.04 based:
- pagure - commit dd1ea30
- python 3.5.2
- pagure celery worker
- gitolite celery worker
- postgresql
- libgit2-0.27.4
- virtual environment = /opt/pag_01/pag_01-server/venv

venv/bin/pip freeze
alembic==1.0.3
amqp==2.3.2
arrow==0.12.1
asn1crypto==0.24.0
bcrypt==3.1.4
billiard==3.5.0.4
binaryornot==0.4.4
bleach==3.0.2
blinker==1.4
celery==4.2.1
certifi==2018.10.15
cffi==1.11.5
chardet==3.0.4
Click==7.0
cryptography==2.4.1
defusedxml==0.5.0
docutils==0.14
Flask==1.0.2
Flask-WTF==0.14.2
idna==2.7
itsdangerous==1.1.0
Jinja2==2.10
kitchen==1.2.5
kombu==4.2.1
Mako==1.0.7
Markdown==2.6.11
MarkupSafe==1.1.0
munch==2.3.2
Pillow==5.3.0
pkg-resources==0.0.0
psutil==5.4.8
psycopg2==2.7.6.1
pycparser==2.19
pygit2==0.27.2
python-dateutil==2.7.5
python-editor==1.0.3
python-openid-cla==1.2
python-openid-teams==1.1
python3-openid==3.1.0
pytz==2018.7
redis==2.10.6
requests==2.20.1
six==1.11.0
SQLAlchemy==1.2.14
straight.plugin==1.5.0
urllib3==1.24.1
vine==1.1.4
webencodings==0.5.1
Werkzeug==0.14.1
WTForms==2.2.1

Error trace:


[ERROR] celery.app.trace: Task pagure.lib.tasks.update_git[a48fae7d-12d9-4d83-8955-1691c3dceacc] raised unexpected: PagurePushDenied('Remote hook declined the push: Traceback (most recent call last):\nFile "hooks/pre-receive", line 19, in <module>\nimport pagure.lib\nImportError: No module named pagure.lib',)
Traceback (most recent call last):
File "/opt/pag_01/pag_01-server/pagure/lib/git.py", line 1040, in push
env=env,
File "/usr/lib/python3.5/subprocess.py", line 626, in check_output
kwargs).stdout
File "/usr/lib/python3.5/subprocess.py", line 708, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['git', 'push', 'origin', 'master:master']' returned non-zero exit status 1
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/pag_01/pag_01-server/venv/lib/python3.5/site-packages/celery/app/trace.py", line 382, in trace_task
R = retval = fun(*args,
kwargs)
File "/opt/pag_01/pag_01-server/venv/lib/python3.5/site-packages/celery/app/trace.py", line 641, in protected_call
return self.run(*args, kwargs)
File "/opt/pag_01/pag_01-server/pagure/lib/tasks_utils.py", line 36, in decorated_function
return function(self, session, *args,
kwargs)
File "/opt/pag_01/pag_01-server/pagure/lib/tasks.py", line 341, in update_git
result = pagure.lib.git._update_git(obj, project)
File "/opt/pag_01/pag_01-server/pagure/lib/git.py", line 290, in _update_git
tempclone.push("pagure", "master", internal="yes")
File "/opt/pag_01/pag_01-server/pagure/lib/git.py", line 1055, in push
"Remote hook declined the push: %s" % "\n".join(remotes)
pagure.exceptions.PagurePushDenied: Remote hook declined the push: Traceback (most recent call last):
File "hooks/pre-receive", line 19, in <module>
import pagure.lib
ImportError: No module named pagure.lib


You're using venv right? Could it be that the hook aren't using it?

Could be, on pagure.wsgi it asks for

# The following is only needed if you did not install pagure
# as a python module (for example if you run it from a git clone).
import sys
sys.path.insert(0, '/opt/pag_01/pag_01-server/')

Then on apache2 added
python-home=/opt/pag_01/pag_01-server/venv to the WSGIDaemonProcess

And it is running "well" so far, where/how could I confirm if it is or isn't?

Try adding it to /opt/pag_01/pag_01-server/pagure/hooks/files/hookrunner

Adding

import sys
+sys.path.insert(0, '/opt/pag_01/pag_01-server/')

Helped to pass the pagure.lib issue, then it complained with,

ImportError: No module named wtforms

Since that was already on the venv, it seems to be an issue with venv, I tried this.

import sys
+sys.path.insert(0, '/opt/pag_01/pag_01-server/')
+sys.path.insert(0, '/opt/pag_01/pag_01-server/venv/lib/python3.5/site-packages')

And now i'm getting long trace ending with,

from backports.functools_lru_cache import lru_cache # pragma: no cover
ImportError: No module named backports.functools_lru_cache

Should I add the full trace?

I find very interesting how much things changes from one environment to another even when using pip.

What version of arrow it's used on the pagure's env?

Well after setting the right python env, now it's all set.

Just needed to add,
sys.path.insert(0, '/opt/pag_01/pag_01-server/')

like pagure.wsgi
PR #4051

Thanks to @altendky from #python who help me figure it out.

Login to comment on this ticket.

Metadata