CKAN server down after installing ckanext-plugin extension - python-2.7

I'm trying to install the CKAN ckanext-spatial plugin by following the step-by-step instructions listed below.
http://docs.ckan.org/projects/ckanext-spatial/en/latest/install.html#ubuntu-12-04-postgresql-9-1-and-postgis-1-5
After installation and configuration, I get the following apache server error when trying to access the site homepage. CKAN is currently unusable. Do I need to upgrade the version of GeoAlchemy or is this an issue with the extension?
mod_wsgi (pid=29881): Target WSGI script '/etc/ckan/default/apache.wsgi' cannot be loaded as Python module.
mod_wsgi (pid=29881): Exception occurred processing WSGI script '/etc/ckan/default/apache.wsgi'.
Traceback (most recent call last):
File "/etc/ckan/default/apache.wsgi", line 10, in
application = loadapp('config:%s' % config_filepath)
File "/usr/lib/ckan/default/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 247, in loadapp
return loadobj(APP, uri, name=name, **kw)
File "/usr/lib/ckan/default/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 271, in loadobj
global_conf=global_conf)
File "/usr/lib/ckan/default/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 296, in loadcontext
global_conf=global_conf)
File "/usr/lib/ckan/default/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 320, in _loadconfig
return loader.get_context(object_type, name, global_conf)
File "/usr/lib/ckan/default/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 454, in get_context
section)
File "/usr/lib/ckan/default/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 476, in _context_from_use
object_type, name=use, global_conf=global_conf)
File "/usr/lib/ckan/default/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 406, in get_context
global_conf=global_conf)
File "/usr/lib/ckan/default/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 296, in loadcontext
global_conf=global_conf)
File "/usr/lib/ckan/default/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 328, in _loadegg
return loader.get_context(object_type, name, global_conf)
File "/usr/lib/ckan/default/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 620, in get_context
object_type, name=name)
File "/usr/lib/ckan/default/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 646, in find_egg_entry_point
possible.append((entry.load(), protocol, entry.name))
File "/usr/lib/ckan/default/lib/python2.7/site-packages/distribute-0.6.24-py2.7.egg/pkg_resources.py", line 1989, in load
entry = import(self.module_name, globals(),globals(), ['name'])
File "/usr/lib/ckan/default/src/ckan/ckan/config/middleware.py", line 26, in
from ckan.config.environment import load_environment
File "/usr/lib/ckan/default/src/ckan/ckan/config/environment.py", line 17, in
import ckan.model as model
File "/usr/lib/ckan/default/src/ckan/ckan/model/init.py", line 7, in
import vdm.sqlalchemy
File "/usr/lib/ckan/default/lib/python2.7/site-packages/vdm/sqlalchemy/init.py", line 32, in
from tools import Repository
File "/usr/lib/ckan/default/lib/python2.7/site-packages/vdm/sqlalchemy/tools.py", line 33, in
raise ValueError("VDM only works with SQLAlchemy versions 0.4 through 0.7, not: %s" % sqav)
ValueError: VDM only works with SQLAlchemy versions 0.4 through 0.7, not: 1.0.12

To reiterate the important bit, the error message says:
VDM only works with SQLAlchemy versions 0.4 through 0.7, not: 1.0.12
So it looks like you upgraded SQLAlchemy to the latest version somehow. This happens if you use the --upgrade flag when pip installing something, although the instructions you mention don't say to do that, so I'm not quite sure how you ended up with this version of SQLAlchemy.
I suggest you install the vdm and SQLAlchemy combination that is in the current ckan requirements which is currently:
pip install SQLAlchemy==0.9.6 vdm==0.13
and I believe this is backwards compatible with all ckan versions. (Remember to run pip with your virtualenv activated)

Fixed it using the following command to correct my version of sqlalchemy.
pip install -r /usr/lib/ckan/default/src/ckan/pip-requirements.txt.
This seemed to fix the error.

Related

KivyMD on a Mac: running kitchen_sink raises an error in kivytoast.py

On a Macbook Pro (Catalina), Python 3.8, interested in developing Android apps in Kivy using KivyMD. I took the following steps to install KivyMD:
create the virtual environment (virtmd), then activated it (source /virtmd/bin/activate)
in this virtual environment, installed the following via pip: Pillow, kivy
git-cloned KivyMD as per the link suggested on the GitHub page
Ran the pip install .
All this ran seamlessly with no hitch or errors. pip freeze shows the following installed items:
certifi==2021.5.30
charset-normalizer==2.0.4
docutils==0.17.1
idna==3.2
Kivy==2.0.0
Kivy-Garden==0.1.4
kivymd # file:///Users/robinhahn/PyProg/kvKivyMD/KivyMD
Pillow==8.3.1
Pygments==2.9.0
requests==2.26.0
urllib3==1.26.6
I was following a Codemy video tutorial and noticed that the presenter's pip freeze showed 4 more entries:
chardet==4.0.0
kivy-deps.angle==0.3.0
kivy-deps.glew==0.3.0
kivy-deps.sdl2==0.3.1
Cd'ed into the /demos/kitchen_sink folder, ran 'python3 main.py' which failed, raising this error, the last few lines of the traceback appear to focus on a file called kivytoast.py:
File "main.py", line 144, in <module>
KitchenSinkApp().run()
File "/Users/robinhahn/PyProg/kvKivyMD/virtmd/lib/python3.8/site-packages/kivy/app.py", line 949, in run
self._run_prepare()
File "/Users/robinhahn/PyProg/kvKivyMD/virtmd/lib/python3.8/site-packages/kivy/app.py", line 944, in _run_prepare
self.dispatch('on_start')
File "_event.pyx", line 709, in kivy._event.EventDispatcher.dispatch
File "main.py", line 65, in on_start
Builder.load_file(
File "/Users/robinhahn/PyProg/kvKivyMD/virtmd/lib/python3.8/site-packages/kivy/lang/builder.py", line 306, in load_file
return self.load_string(data, **kwargs)
File "/Users/robinhahn/PyProg/kvKivyMD/virtmd/lib/python3.8/site-packages/kivy/lang/builder.py", line 373, in load_string
parser = Parser(content=string, filename=fn)
File "/Users/robinhahn/PyProg/kvKivyMD/virtmd/lib/python3.8/site-packages/kivy/lang/parser.py", line 402, in __init__
self.parse(content)
File "/Users/robinhahn/PyProg/kvKivyMD/virtmd/lib/python3.8/site-packages/kivy/lang/parser.py", line 508, in parse
self.execute_directives()
File "/Users/robinhahn/PyProg/kvKivyMD/virtmd/lib/python3.8/site-packages/kivy/lang/parser.py", line 472, in execute_directives
mod = __import__(package)
File "/Users/robinhahn/PyProg/kvKivyMD/virtmd/lib/python3.8/site-packages/kivymd/toast/__init__.py", line 11, in <module>
from .kivytoast import toast
File "/Users/robinhahn/PyProg/kvKivyMD/virtmd/lib/python3.8/site-packages/kivymd/toast/kivytoast/__init__.py", line 3, in <module>
from .kivytoast import toast
File "/Users/robinhahn/PyProg/kvKivyMD/virtmd/lib/python3.8/site-packages/kivymd/toast/kivytoast/kivytoast.py", line 72, in <module>
class Toast(BaseDialog):
File "/Users/robinhahn/PyProg/kvKivyMD/virtmd/lib/python3.8/site-packages/kivymd/toast/kivytoast/kivytoast.py", line 90, in Toast
self, instance_label: Label, texture_size: list[int, int]
TypeError: 'type' object is not subscriptable
Still somewhat of a novice, and not really sure how to proceed from here.
ETA: I brought this up in VSCode and the last word:
list[int, int]
was squiggly-underlined, indicating it's the offending item. I have no idea what 'type' object is not subscriptable means or how to fix it.
Thanks to all who read and ponder this problem.
I'm on the same course right now and just got to that file with the same issue. I followed the path to the 'kivytoast.py' file and changed the following line (line 89):
def label_check_texture_size(self, instance_label: Label, texture_size: list([int, int])) -> NoReturn:
The kivymd devs seemed to have made a mistake and did list[int, int] instead of list([int,int]). You could also just leave it as [int,int] and it would work the same since it is alread in list format. Goodluck with the rest of your course!

Installing networkx 1.9.1 on Jython 2.7.0

From the official networkx Version 1.9 notes and API changes:
Basic support is added for Jython 2.7 [...], although they remain not officially supported.
How can I install networkx on Jython?
What I have tried:
Installed jython2.7.0 on my Ubuntu 14.04 32bit.
Tried installing networkx via pip:
sudo /opt/jython2.7.0/bin/pip install networkx
which downloaded the file networkx-1.9.1-py2.py3-none-any.whl, but then errored at some point:
Exception:
Traceback (most recent call last):
File "/opt/jython2.7.0/Lib/site-packages/pip/basecommand.py", line 133, in main
status = self.run(options, args)
File "/opt/jython2.7.0/Lib/site-packages/pip/commands/install.py", line 325, in run
requirement_set.install(
File "/opt/jython2.7.0/Lib/site-packages/pip/commands/install.py", line 325, in run
requirement_set.install(
File "/opt/jython2.7.0/Lib/site-packages/pip/req/req_set.py", line 633, in install
requirement.install(
File "/opt/jython2.7.0/Lib/site-packages/pip/req/req_install.py", line 719, in install
self.move_wheel_files(self.source_dir, root=root)
File "/opt/jython2.7.0/Lib/site-packages/pip/req/req_install.py", line 990, in move_wheel_files
move_wheel_files(
File "/opt/jython2.7.0/Lib/site-packages/pip/wheel.py", line 154, in move_wheel_files
compileall.compile_dir(source, force=True, quiet=True)
File "/opt/jython2.7.0/Lib/compileall.py", line 56, in compile_dir
if not compile_dir(fullname, maxlevels - 1, dfile, force, rx,
File "/opt/jython2.7.0/Lib/compileall.py", line 56, in compile_dir
if not compile_dir(fullname, maxlevels - 1, dfile, force, rx,
File "/opt/jython2.7.0/Lib/compileall.py", line 50, in compile_dir
if not compile_file(fullname, ddir, force, rx, quiet):
File "/opt/jython2.7.0/Lib/compileall.py", line 99, in compile_file
ok = py_compile.compile(fullname, None, dfile, True)
File "/opt/jython2.7.0/Lib/compileall.py", line 99, in compile_file
ok = py_compile.compile(fullname, None, dfile, True)
File "/opt/jython2.7.0/Lib/py_compile.py", line 99, in compile
_py_compile.compile(file, cfile, dfile)
File "/opt/jython2.7.0/Lib/py_compile.py", line 99, in compile
_py_compile.compile(file, cfile, dfile)
RuntimeException: java.lang.RuntimeException: Method code too large!
I added the following print statements before the _py_compile.compile(file, cfile, dfile) functions:
print "file: %s" % file
print "cfile: %s" % cfile
print "dfile: %s" % dfile
which gave me:
file: /tmp/pip_build_vagrant/networkx/networkx/generators/atlas.py
cfile: None
dfile: None
Did anybody manage to install networkx 1.9 on Jython2.7.0?
Here's how to get networkx installed in Jython:
Go to PyPI and download the networkx source package.
extract the networkx source into a folder.
in the source folder, delete the file networkx/generators/atlas.py (this is the file that's too large for Jython to parse. It doesn't work in Jython anyways, so just delete it).
in the file networkx/readwrite/gml.py, remove all mentions of lib2to3 (due to a current bug in Jython, lib2to3 is not available):
on lines 44-46, comment out imports from lib2to3
on lines around 75, change:
rtp_fix_unicode = RefactoringTool(['lib2to3.fixes.fix_unicode'],
{'print_function': True})
to:
rtp_fix_unicode = None
around line 145, in the try-except statement, remove ParseError and TokenError.
go back to the source folder, and run:
jython/pip install .
Or alternatively, if you don't have pip for jython:
jython setup.py install
It should install successfully, and you should be able to import networkx in Jython now.

ImportError: No module named phonenumbers in Odoo (OpenERP v8)

I'm trying to intall the asterisk_click2dial module on ODOO and this error comes to me in the log file:
ValueError: Routing: posting a message without model should be with a parent_id (private mesage).
2015-03-09 15:23:38,262 11093 ERROR ? werkzeug: Error on request:
Traceback (most recent call last):
File "/home/odoo/odoo/lib/python2.7/site-packages/werkzeug/serving.py", line 177, in run_wsgi
execute(self.server.app)
File "/home/odoo/odoo/lib/python2.7/site-packages/werkzeug/serving.py", line 165, in execute
application_iter = app(environ, start_response)
File "/opt/odoo/openerp/service/server.py", line 281, in app
return self.app(e, s)
File "/opt/odoo/openerp/service/wsgi_server.py", line 216, in application
return application_unproxied(environ, start_response)
File "/opt/odoo/openerp/service/wsgi_server.py", line 202, in application_unproxied
result = handler(environ, start_response)
File "/opt/odoo/openerp/http.py", line 1274, in __call__
self.load_addons()
File "/opt/odoo/openerp/http.py", line 1293, in load_addons
m = __import__('openerp.addons.' + module)
File "/opt/odoo/openerp/modules/module.py", line 79, in load_module
mod = imp.load_module('openerp.addons.' + module_part, f, path, descr)
File "/opt/odoo/addons/base_phone/__init__.py", line 23, in <module>
from . import wizard
File "/opt/odoo/addons/base_phone/wizard/__init__.py", line 23, in <module>
from . import number_not_found
File "/opt/odoo/addons/base_phone/wizard/number_not_found.py", line 25, in <module>
import phonenumbers
ImportError: No module named phonenumbers
The problem is just that I installed that module (phonenumbers) plus the py-Asterisk module without errors using pip install phonenumbers and pip install py-Asterisk and the error persists.
I noticed I have at least two versions of python installed (2.6 and 2.7) but both modules are installed at the same version from odoo (I can see the modules in the python2.7 cli when, for example, I write phonenumbers or search).
Has anybody any idea what is happening to me? I'd be gratefull for some specific response. Thanks.
Here the connector's page: OpenERP - Asterisk connector
Ok, my bad. During odoo instalation I created a virtual environment under the Odoo system user account which was used solely by the Odoo server so I just need to install these modules under that enviorment. This works for me:
First let’s switch from root to the odoo user, then create a new virtual environment called odoo and activate it:
su - odoo
/usr/local/bin/virtualenv --python=/usr/local/bin/python2.7 odoo
source odoo/bin/activate
(If you have the virtual environment created like me just ignore the second line). Before starting the module installation we need to add the path to the PostgreSQL binaries, otherwise the PsycoPG2 module install will fail (I ignored this one too):
export PATH=/usr/pgsql-9.3/bin:$PATH
Then I can do pip install... Thank you all for your help.

Trying to install Django

I have been trying to install Django correctly for a while to no avail.
C:\Python34\Scripts\pip.exe install C:\Python34\Lib\site-packages\Django-1.7.2\Django-1.7.2\setup.py
raises an exception and stores the following in a log file:
C:\Python34\Scripts\pip run on 01/12/15 17:47:02
Exception:
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\pip\basecommand.py", line 122, in main
status = self.run(options, args)
File "C:\Python34\lib\site-packages\pip\commands\install.py", line 257, in run
InstallRequirement.from_line(name, None))
File "C:\Python34\lib\site-packages\pip\req.py", line 172, in from_line
return cls(req, comes_from, url=url, prereleases=prereleases)
File "C:\Python34\lib\site-packages\pip\req.py", line 70, in __init__
req = pkg_resources.Requirement.parse(req)
File "C:\Python34\lib\site-packages\pip\_vendor\pkg_resources.py", line 2606, in parse
reqs = list(parse_requirements(s))
File "C:\Python34\lib\site-packages\pip\_vendor\pkg_resources.py", line 2544, in parse_requirements
line, p, specs = scan_list(VERSION,LINE_END,line,p,(1,2),"version spec")
File "C:\Python34\lib\site-packages\pip\_vendor\pkg_resources.py", line 2512, in scan_list
raise ValueError("Expected "+item_name+" in",line,"at",line[p:])
ValueError: ('Expected version spec in', 'C:\\Python34\\Lib\\site-packages\\Django-1.7.2\\Django-1.7.2\\setup.py', 'at', ':\\Python34\\Lib\\site-packages\\Django-1.7.2\\Django-1.7.2\\setup.py')
any help would be greatly appreciated!
THANK YOU
For pip install refer to the directory containing setup.py.
C:\Python34\Scripts\pip.exe install C:\Python34\Lib\site-packages\Django-1.7.2\Django-1.7.2\
But since your path has site-packages in it already (e.g. C:\Python34\Lib\site-packages\) it would seem that it is already installed.
Other alternatives are:
pip install django==1.7.2
pip install django==1.7
python C:...\Django-1.7.2\setup.py install

Django - rest framework errors when python runserver

File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/handlers.py", line 85, in run
self.result = application(self.environ, self.start_response)
File "/Library/Python/2.7/site-packages/dj_static.py", line 83, in __call__
return self.application(environ, start_response)
File "/Library/Python/2.7/site-packages/django/core/handlers/wsgi.py", line 255, in __call__
response = self.get_response(request)
File "/Library/Python/2.7/site-packages/django/core/handlers/base.py", line 178, in get_response
response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
File "/Library/Python/2.7/site-packages/django/core/handlers/base.py", line 220, in handle_uncaught_exception
if resolver.urlconf_module is None:
File "/Library/Python/2.7/site-packages/django/core/urlresolvers.py", line 342, in urlconf_module
self._urlconf_module = import_module(self.urlconf_name)
File "/Library/Python/2.7/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/Users/WillRedington/Desktop/Django Projects/propadev/propvocab/urls.py", line 3, in <module>
from rest_framework import routers
File "/Library/Python/2.7/site-packages/rest_framework/routers.py", line 23, in <module>
from rest_framework import views
File "/Library/Python/2.7/site-packages/rest_framework/views.py", line 11, in <module>
from rest_framework.compat import HttpResponseBase, View
File "/Library/Python/2.7/site-packages/rest_framework/compat.py", line 13, in <module>
from django.utils.six.moves.urllib import parse as urlparse
ImportError: No module named urllib
The server error message: [17/Dec/2014 16:26:45] "GET / HTTP/1.1" 500 59
This is checking if python returns the modules:
>>> import django.utils.six.moves
>>> import django.utils.six.moves.urllib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named urllib
>>>
My current python version is 2.7.2, Django is 1.5.1, rest framework is in 2.7 site-package.
I have already tried uninstalling and reinstalling Django several times and get the same error.
This is running on Mac OS X 10.9.5, please help me, I've been at this for 5 hours.
it seems like a dependency error. Maybe you downgraded your django, or randomly installed the rest framework package without controlling the dependencies.
django.utils.six.moves.urllib doesnt exist in django==1.5.1 yet. You can try to upgrade django to 1.5.7 for example. Then this import will work. Other things might still be broken though, I can´t tell from here. If you post the output of pip freeze here, it may be easier to help.
You aren´t working in a virtual environment, which is dangerous for dependencies. Best is to make a virtualenv, then install your packages with pip, taking care of dependencies.
Then run:
pip freeze > requirements.txt
and use that file in the future like this:
pip install -r requirements.txt
and edit the file accordingly if you install, update or remove packages.
Something that might be of interest is this: it generally never works to uninstall and reinstall the same package several times; if it doesn´t work once, it won´t work the second time either.
As someone mentioned before my response wasn't really an answer. I solved this error and potentially many more by installing a python virtual environment. To do this run the following
sudo pip install virtualenv
Then create a new folder for your virtual environments. cd into the created folder.
cd myvirtualenv
Then create a new virtual environment by running the following:
virtualenv venv
To run the virtual env:
source venv/bin/activate
This makes a seperate environment with it's own site packages, which is essential for any python developer, especially when working on multiple projects.
Source: http://docs.python-guide.org/en/latest/dev/virtualenvs/