Fix "ImportError: cannot import name deploy" when running keystone

When trying to access keystone's address, for example http://localhost:5000/v3, I got this apache2's error:

2018-03-09 01:51:42.468036 mod_wsgi (pid=21691): Target WSGI script '/usr/bin/keystone-wsgi-public' cannot be loaded as Python module.
2018-03-09 01:51:42.468106 mod_wsgi (pid=21691): Exception occurred processing WSGI script '/usr/bin/keystone-wsgi-public'.
2018-03-09 01:51:42.468137 Traceback (most recent call last):
2018-03-09 01:51:42.468164   File "/usr/bin/keystone-wsgi-public", line 6, in <module>
2018-03-09 01:51:42.468248     from keystone.server.wsgi import initialize_public_application
2018-03-09 01:51:42.468262   File "/usr/lib/python2.7/dist-packages/keystone/server/wsgi.py", line 30, in <module>
2018-03-09 01:51:42.468336     from keystone.version import service as keystone_service
2018-03-09 01:51:42.468349   File "/usr/lib/python2.7/dist-packages/keystone/version/service.py", line 19, in <module>
2018-03-09 01:51:42.468442     from paste import deploy
2018-03-09 01:51:42.468466 ImportError: cannot import name deploy
2018-03-09 01:51:43.818367 mod_wsgi (pid=21687): Target WSGI script '/usr/bin/keystone-wsgi-public' cannot be loaded as Python module.
2018-03-09 01:51:43.818420 mod_wsgi (pid=21687): Exception occurred processing WSGI script '/usr/bin/keystone-wsgi-public'.
2018-03-09 01:51:43.818450 Traceback (most recent call last):
2018-03-09 01:51:43.818478   File "/usr/bin/keystone-wsgi-public", line 6, in <module>
2018-03-09 01:51:43.818559     from keystone.server.wsgi import initialize_public_application
2018-03-09 01:51:43.818574   File "/usr/lib/python2.7/dist-packages/keystone/server/wsgi.py", line 30, in <module>
2018-03-09 01:51:43.818646     from keystone.version import service as keystone_service
2018-03-09 01:51:43.818660   File "/usr/lib/python2.7/dist-packages/keystone/version/service.py", line 19, in <module>
2018-03-09 01:51:43.818752     from paste import deploy
2018-03-09 01:51:43.818776 ImportError: cannot import name deploy
2018-03-09 01:54:04.847216 mod_wsgi (pid=24505): Target WSGI script '/usr/bin/keystone-wsgi-public' cannot be loaded as Python module.
2018-03-09 01:54:04.847274 mod_wsgi (pid=24505): Exception occurred processing WSGI script '/usr/bin/keystone-wsgi-public'.
2018-03-09 01:54:04.847302 Traceback (most recent call last):
2018-03-09 01:54:04.847330   File "/usr/bin/keystone-wsgi-public", line 6, in <module>
2018-03-09 01:54:04.847416     from keystone.server.wsgi import initialize_public_application
2018-03-09 01:54:04.847431   File "/usr/lib/python2.7/dist-packages/keystone/server/wsgi.py", line 30, in <module>
2018-03-09 01:54:04.847505     from keystone.version import service as keystone_service
2018-03-09 01:54:04.847519   File "/usr/lib/python2.7/dist-packages/keystone/version/service.py", line 19, in <module>
2018-03-09 01:54:04.847615     from paste import deploy
2018-03-09 01:54:04.847639 ImportError: cannot import name deploy

It's because when keystone was installed, the PasteDeploy package was not installed properly. I fixed the issue following these steps:

1. Uninstall PasteDeploy

sudo pip uninstall PasteDeploy

2. Reinstall it

sudo pip install 'PasteDeploy>=1.5.2'

3. Verify by running this command:

python -c 'from paste import deploy'

If the result is blank, PasteDeploy was installed correctly now.



Comments