CKAN install on Ubuntu (cannot create std instance) - python-2.7

I'm trying to install CKAN 1.8 on a virtual machine with Ubuntu 10.04.
The installation ended well, but when I create the std instance, appears an error in Python that I can not solve.
Can anyone help me with this?
Transcription of the messages in the terminal:
egov#egov-VirtualBox:~$ sudo ckan-create-instance std default.vm.buildkit yes
Installing or upgrading CKAN std ...
Ensuring users and groups are set up correctly ...
Ensuring directories exist for std CKAN INSTANCE ...
Disabling the crontab for the ckanstd user ...
Putting CKAN into maintenance mode ...
Site std disabled.
To activate the new configuration, you need to run:
service apache2 reload
Enabling site std.maint.
To activate the new configuration, you need to run:
service apache2 reload
* Reloading web server config apache2
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
[ OK ]
Setting log file permissions so that both Apache and cron jobs can log to the same place ...
Ensuring who.ini file exists ...
Ensuring wsgi.py file exists ...
Making sure PostgreSQL is running ...
Setting the password of the std user in PostgreSQL
Setting the std user password ...
ALTER ROLE
Ensuring the std database exists ...
Overwriting the existing Apache config ...
Performing any database upgrades ...
Traceback (most recent call last):
File "/usr/bin/paster", line 4, in <module>
command.run()
File "/usr/lib/python2.7/dist-packages/paste/script/command.py", line 104, in run
invoke(command, command_name, options, args[1:])
File "/usr/lib/python2.7/dist-packages/paste/script/command.py", line 143, in invoke
exit_code = runner.run(args)
File "/usr/lib/python2.7/dist-packages/paste/script/command.py", line 238, in run
result = self.command()
File "/usr/lib/pymodules/python2.7/ckan/lib/cli.py", line 120, in command
self._load_config()
File "/usr/lib/pymodules/python2.7/ckan/lib/cli.py", line 82, in _load_config
load_environment(conf.global_conf, conf.local_conf)
File "/usr/lib/pymodules/python2.7/ckan/config/environment.py", line 141, in load_environment
p.load('synchronous_search')
File "/usr/lib/pymodules/python2.7/ckan/plugins/core.py", line 122, in load
service = _get_service(plugin)
File "/usr/lib/pymodules/python2.7/ckan/plugins/core.py", line 77, in _get_service
return plugin.load()(name=name)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1989, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/usr/lib/pymodules/python2.7/ckan/lib/search/__init__.py", line 2, in <module>
from pylons import config, c
ImportError: cannot import name c
Bringing the std INSTANCE out of maintenance mode ...
Site std.maint disabled.
To activate the new configuration, you need to run:
service apache2 reload
Enabling site std.
To activate the new configuration, you need to run:
service apache2 reload
* Reloading web server config apache2
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
[ OK ]
Reloading apache ...
* Reloading web server config apache2
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
[ OK ]
Enabling crontab for the ckanstd user ...

The issue is at the end of the stack trace:
File "/usr/lib/pymodules/python2.7/ckan/lib/search/__init__.py", line 2, in <module>
from pylons import config, c
ImportError: cannot import name c
This suggests pylons (a required library) may not install correctly. You could check this by doing:
$ python
>>> import pylons
If that fails then something has gone wrong in the install and pylons is not installed (as it should be).
At that point it would be worth trying a reinstall.
Please let me know if this helps (or not) and will try to assist further.

Related

AttributeError: module 'signal' has no attribute 'SIGHUP'

I am trying to integrate mod_wsgi into my django project on Windows 10. While I was able to install mod_wsgi into my virtual environment, I am running into errors while trying the command python manage.py runmodwsgi.
(venv) PS D:\Tutorials\Python\Projects\ADSS> python manage.py runmodwsgi
Successfully ran command.
Server URL : http://localhost:8000/
Server Root : C:/Users/admin/AppData/Local/Temp/mod_wsgi-localhost-8000-admin
Server Conf : C:/Users/admin/AppData/Local/Temp/mod_wsgi-localhost-8000-admin/httpd.conf
Error Log File : C:/Users/admin/AppData/Local/Temp/mod_wsgi-localhost-8000-admin/error_log (warn)
Operating Mode : daemon
Request Capacity : 5 (1 process * 5 threads)
Request Timeout : 60 (seconds)
Startup Timeout : 15 (seconds)
Queue Backlog : 100 (connections)
Queue Timeout : 45 (seconds)
Server Capacity : 20 (event/worker), 20 (prefork)
Server Backlog : 500 (connections)
Locale Setting : en_US.cp1252
Traceback (most recent call last):
File "D:\Tutorials\Python\Projects\ADSS\manage.py", line 25, in <module>
execute_from_command_line(sys.argv)
File "D:\Tutorials\Python\Projects\ADSS\venv\lib\site-packages\django\core\management\__init__.py", line 446, in execute_from_command_line
utility.execute()
File "D:\Tutorials\Python\Projects\ADSS\venv\lib\site-packages\django\core\management\__init__.py", line 440, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "D:\Tutorials\Python\Projects\ADSS\venv\lib\site-packages\django\core\management\base.py", line 402, in run_from_argv
self.execute(*args, **cmd_options)
File "D:\Tutorials\Python\Projects\ADSS\venv\lib\site-packages\django\core\management\base.py", line 448, in execute
output = self.handle(*args, **options)
File "D:\Tutorials\Python\Projects\ADSS\venv\lib\site-packages\mod_wsgi\server\management\commands\runmodwsgi.py", line 162, in handle
signal.signal(signal.SIGHUP, handler)
AttributeError: module 'signal' has no attribute 'SIGHUP'
Google seems to suggest that signal.SIGHUP, signal.SIGUSR1 and signal.SIGWINCH as being used by my mod_wsgi installation aren't supported on Windows. So I tried the following two methods in .\venv\Lib\site-packages\mod_wsgi\server\management\commands\runmodwsgi.py:
I tried using the if-condition if platform.system() != 'Linux': as suggested on this Q&A,
I also tried commenting out the lines making use of these signals in this file.
In either case, I kept running across some or the other error, making me wonder if my installation of mod_wsgi is correct at all.
I have been following the instructions as written on mod_wsgi's PyPi listing. I am writing them here for reference:
Obtained a copy of Apache 2.4.54 Win64 from https://www.apachelounge.com/download/
Extracted this zip file and placed the Apache24 folder in my C: as C:\Apache24.
Set Define SRVROOT "c:/Apache24" and Listen 8000 in httpd.conf. Verified that things work and the default homepage is loaded (http://localhost:8000).
Installed Visual Studio C++ build tools using Visual Studio Installer (the 'Desktop development with C++' category).
Installed mod_wsgi into my virtual environment by running the command pip install mod-wsgi in my active virtual environment in an x64 Native Tools Command Prompt for VC2022 window.
Added 'mod_wsgi.server', to the list of INSTALLED_APPS in my settings.py.
Ran python manage.py collectstatic
Ran mod_wsgi-express module-config which output the following three lines, which I placed at the end of my httpd.conf:
LoadFile "C:/Program Files/Python310/python310.dll"
LoadModule wsgi_module "D:/Tutorials/Python/Projects/ADSS/venv/lib/site-packages/mod_wsgi/server/mod_wsgi.cp310-win_amd64.pyd"
WSGIPythonHome "D:/Tutorials/Python/Projects/ADSS/venv"
Ran python manage.py runmodwsgi, which is resulting in the error log I mentioned at the start of my post.
Please throw light on what I might be doing incorrectly.
I also have Visual Studio installed, which I am using for this project.
I changed from port 80 to port 8000 in httpd.conf because my IIS doesn't allow Apache to run on port 80.
Okay. So I found a workaround which works.
Instead of relying on mod_wsgi's buil-in admin script which is triggered by the command python manage.py runmodwsgi, I followed Johnnyboycurtis's method as explained in his video here.
Johnnyboycurtis's method of django application deployment on Apache in Windows environment worked right out of the box. However, apache wasn't serving static files, even though I followed the instructions as per the django documentation here.
So, to serve the static files, I installed WhiteNoise. Now, things seem to be working fine.

ImportError: cannot import name cygrpc

I am trying to use Firebase Native mode on Google App Engine - Standard. My python language is Python 2.7. When I try to from google.cloud import firestore, I get an error ImportError: cannot import name cygrpc
I have deployed virtualenv described in the documentation here.
pip install virtualenv
virtualenv env
source env/bin/activate
My appengine_config.py is
from google.appengine.ext import vendor
import os.path
# Add any libraries installed in the "lib" folder.
vendor.add('lib')
vendor.add(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'lib'))
my_app.py includes
from google.appengine.ext.webapp import template
from google.appengine.ext import ndb
from google.appengine.api import mail
import os
from google.cloud import firestore
(/base/alloc/tmpfs/dynamic_runtimes/python27g/43d5822312de17fd/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py:269)
Traceback (most recent call last):
File "/base/alloc/tmpfs/dynamic_runtimes/python27g/43d5822312de17fd/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/base/alloc/tmpfs/dynamic_runtimes/python27g/43d5822312de17fd/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 311, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/base/alloc/tmpfs/dynamic_runtimes/python27g/43d5822312de17fd/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
File "/base/data/home/apps/s~openbarn-prod/20190602t102855.418624175446659791/main.py", line 4, in <module>
from controllers import server, common, header
File "/base/data/home/apps/s~openbarn-prod/20190602t102855.418624175446659791/controllers/server.py", line 10, in <module>
from google.cloud import firestore
File "/base/data/home/apps/s~openbarn-prod/20190602t102855.418624175446659791/lib/google/cloud/firestore.py", line 18, in <module>
from google.cloud.firestore_v1 import __version__
File "/base/data/home/apps/s~openbarn-prod/20190602t102855.418624175446659791/lib/google/cloud/firestore_v1/__init__.py", line 22, in <module>
from google.cloud.firestore_v1._helpers import GeoPoint
File "/base/data/home/apps/s~openbarn-prod/20190602t102855.418624175446659791/lib/google/cloud/firestore_v1/_helpers.py", line 21, in <module>
import grpc
File "/base/data/home/apps/s~openbarn-prod/20190602t102855.418624175446659791/lib/grpc/__init__.py", line 23, in <module>
from grpc._cython import cygrpc as _cygrpc
ImportError: cannot import name cygrpc
The question I have - can you use Firestore Native mode on Google App Engine Standard using Python 2.7? I need GAE- Standard because we are using Google Endpoint that is not support on GAE-Flex.
The doc here says App Engine Client library integration is not supported on Python2.7 GAE Standard environment. But I am not trying App Engine Client library, I am trying App Engine Server library in GAE Standard Environment.
How do I solve for import error for cygrpc? The solution here, says -
python -m pip install grpcio --ignore-installed
Is this recommended?
It's 2020, and you can now use grpcio (without explicitly adding it yourself as it's a built-in library) w/Cloud Firestore natively on App Engine with Python 2.7. Three things to make this work:
Add google-cloud-firestore to your requirements.txt file and install with pip install -U -t lib -r requirements.txt.
Add these lines to the libraries section of your app.yaml file:
libraries:
- name: grpcio
version: 1.0.0
- name: setuptools
version: 36.6.0
Ensure these lines are in your appengine_config.py file:
import pkg_resources
from google.appengine.ext import vendor
# Set path to your libraries folder.
path = 'lib'
# Add libraries installed in the path folder.
vendor.add(path)
# Add libraries to pkg_resources working set to find the distribution.
pkg_resources.working_set.add_entry(path)
Of course, we do recommend you eventually migrate to Python 3 to take advantage of the greater flexibility the next generations (of Python and App Engine) provide, esp. the ability to tap into other GCP services. However, caveat such a port isn't without effort if your app is complex & deeply-dependent on App Engine's 1st gen built-in services. Most of the suggestions above are derived from this section of the migration docs.
Once you're on Python 3, everything related to 3P libraries on App Engine becomes much easier, as I demonstrate in this other SO answer.
A while ago GRPC wasn't supported on GAE standard, see GRPC and types import error in App Engine Datastore. I didn't try since, but I don't see newer activity on issue 149.
Also the cython reference in the traceback suggests that it may include compiled code, which would violate the pure python standard environment sandbox restrictions that applies to the code you deploy.
Make sure that your installed python version bit(32/64) and your system bit(32/64) are matched.
If they are not matched please follow the solution mentioned at https://azurelessons.com/cannot-import-name-cygrpc/

ImportError: no module named pwd in app engine

I'm trying to run a python flask based application on google app engine using cloud datastore. I'm following the bookshelf example -
https://cloud.google.com/python/getting-started/using-cloud-datastore
Everything seems to work in local machine but on app engine, I'm getting
ImportError: No module named pwd, which is being imported by oauth2client library.
Is there anything I'm missing. Any help will be appreciated.
The question referenced as duplicate is different. The application there seems to fail only locally, whereas for me everything works locally but fails to work in GAE.
Here's the stack trace (partial) -
...
1384/v1.394932573930853146/application/home/model.py", line 16, in save_user
ds = get_client()
File "/base/data/home/apps/s~bookshelf-1384/v1.394932573930853146/application/home/model.py", line 7, in get_client
return datastore.Client('bookshelf-1384')#current_app.config['PROJECT_ID'])
File "/base/data/home/apps/s~bookshelf-1384/v1.394932573930853146/lib/gcloud/datastore/client.py", line 173, in __init__
super(Client, self).__init__(credentials, http)
File "/base/data/home/apps/s~bookshelf-1384/v1.394932573930853146/lib/gcloud/client.py", line 122, in __init__
credentials = get_credentials()
File "/base/data/home/apps/s~bookshelf-1384/v1.394932573930853146/lib/gcloud/credentials.py", line 82, in get_credentials
return client.GoogleCredentials.get_application_default()
File "/base/data/home/apps/s~bookshelf-1384/v1.394932573930853146/lib/oauth2client/client.py", line 1288, in get_application_default
return GoogleCredentials._get_implicit_credentials()
File "/base/data/home/apps/s~bookshelf-1384/v1.394932573930853146/lib/oauth2client/client.py", line 1273, in _get_implicit_credentials
credentials = checker()
File "/base/data/home/apps/s~bookshelf-1384/v1.394932573930853146/lib/oauth2client/client.py", line 1226, in _implicit_credentials_from_files
credentials_filename = _get_well_known_file()
File "/base/data/home/apps/s~bookshelf-1384/v1.394932573930853146/lib/oauth2client/client.py", line 1392, in _get_well_known_file
default_config_dir = os.path.join(os.path.expanduser('~'),
File "/base/data/home/runtimes/python27/python27_dist/lib/python2.7/posixpath.py", line 268, in expanduser
import pwd
ImportError: No module named pwd
The error is caused by http://github.com/google/oauth2client/issues/578.
It will be fixed in a couple of weeks with a new AppEngine SDK. In the meantime you can downgrade the version of the oauth2client library in your app.yaml file.
I had this same issue which is a known issue with the SDK. I tried the other solutions suggested on SO (see Google App Engine 'No module named pwd') but it didn't work. I found a work around by installing an older version of oauth2client-2.0.0 overwriting the oauth2client-4.0.0 that came with the pubsub pip install. Try running
pip install -t ./lib/ --upgrade --force-reinstall oauth2client==2.0.0
in the project directory and rerunning.

datastore error after migrating to python2.7 - works fine on localhost

I understand that google.appengine.dist was removed from python2.7. What should I use instead?
application works fine on localhost, deployment seems to be successful, but I am getting this message online:
Error: Server Error
The server encountered an error and could not complete your request.
If the problem persists, please report your problem and mention this error message and the query that caused it.
Here is what my log says:
Traceback (most recent call last):
File
"/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 196, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 255, in _LoadHandler
handler = __import__(path[0])
File "/base/data/home/apps/s~quick-test/1.368856085074570769/django_bootstrap.py", line 54, in <module>
from google.appengine.dist import use_library
ImportError: No module named dist
Here's the line 54 from django_bootstrap.py:
from google.appengine.dist import use_library
use_library('django', '1.2')
GAE LAuncher version 1.8.2, had this problem with 1.8 too.
Python 2.7 configuration requires third-party libraries specified in app.yaml, so it might be sufficient to have this in your app.yaml file:
libraries:
- name: django
version: "1.2"
You can also use webapp2 that includes Django’s templating engine. Version 1.2 included with the SDK is part of App Engine, and you do not need to bundle Django yourself to use it.
import os
from google.appengine.ext.webapp import template
Also, with this code you don't need to call use_library() to explicitly select a Django version:
webapp_django_version = "1.2"

Django Import Error using EC2 and bitnami

I am trying to deploy my django app to amazon's ec2. I ran into some trouble getting my site-packages and my middleware working on the ec2 server. i am using bitnami djangostack for my AMI but am confused where on the server to put my site-packages (like registration south etc) and where to put my middleware (like pagination).
right now i am running the server and getting the following error:
Traceback (most recent call last):
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/core/servers/basehttp.py", line 283, in run
self.result = application(self.environ, self.start_response)
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/contrib/staticfiles/handlers.py", line 68, in __call__
return self.application(environ, start_response)
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/core/handlers/wsgi.py", line 250, in __call__
self.load_middleware()
File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/core/handlers/base.py", line 47, in load_middleware
raise exceptions.ImproperlyConfigured('Error importing middleware %s: "%s"' % (mw_module, e))
ImproperlyConfigured: Error importing middleware pagination.middleware: "No module named pagination.middleware"
you can see the error at the following link
site-packages is not somewhere you manually add items. Let Python's installation tools - pip and easy_install do the job for you.
As for middleware, it can go anywhere that is in your PYTHONPATH. The best place to put it is in a file that is in one of your app's directory (same place you see models.py); typically this file is called middleware.py
If the middleware is part of a third-party application; first install that application. Typically this is done with sudo easy_install package-name. Use sudo to install it in the global python site-packages directory.
A better approach is to use a virtual environment.