CKAN Development Install Issue: AttributeError: &#

2019-03-15 12:35发布

问题:

I've done a CKAN development install and am running with debug = true in my development.ini file. On visiting localhost:5000 I get an error with a traceback whose end point is the error:

AttributeError: 'module' object has no attribute 'css/main.debug.css'

Caused by the call in lib/helpers.py:

r = getattr(fanstatic_resources, resource)

Any idea what I'm doing wrong and what I can do to fix this error.

回答1:

You need to run the less script from the bin directory in the CKAN source code to build the main.debug.css file. There is some documentation of this but it's not yet integrated with the rest of the CKAN docs (i.e. there's no link to it anywhere, we have a ticket to fix this).

This works on Ubuntu 12.04, you might need to have your virtualenv active when you do this:

sudo apt-get install nodejs npm
npm install less nodewatch
./bin/less # Assuming you're in your ckan dir e.g. `~/pyenv/src/ckan`

Now restart the paster serve development.ini command and it should work.

Generally speaking whenever running CKAN 2.0 for development you should:

  • Have debug = True in your ini file
  • Have ./bin/less running in a terminal all the time


回答2:

Beware that apt-get install nodejs installs nodejs and NOT node in /usr/bin, at least in Ubuntu 12.10 (I didn't check in other distributions). This throws errors since both ckan/bin/less as well as ckan/node_modules/less/bin/lessc are calling node. So either create a softlink in /usr/bin or modify the scripts (#!/usr/bin/env nodejs).



回答3:

I got few errors while installing the packages. Following is the solution (according to official CKAN docs) for impatient:

cp /usr/lib/ckan/default/src/ckan/ckan/public/base/css/main.css /usr/lib/ckan/default/src/ckan/ckan/public/base/css/main.debug.css



回答4:

I'm using an ubuntu 12.04 and experiencing some problems with this

Was getting this error after following Sean's answers and running

npm install less nodewatch

and got this error:

(default)root@ckan:/# npm install less nodewatch
npm http GET https://registry.npmjs.org/less
npm http GET https://registry.npmjs.org/nodewatch
npm ERR! Error: failed to fetch from registry: less
npm ERR!     at /usr/share/npm/lib/utils/npm-registry-client/get.js:139:12
npm ERR!     at cb (/usr/share/npm/lib/utils/npm-registry-client/request.js:31:9)
npm ERR!     at Request._callback (/usr/share/npm/lib/utils/npm-registry-client/request.js:136:18)
npm ERR!     at Request.callback (/usr/lib/nodejs/request/main.js:119:22)
npm ERR!     at Request.<anonymous> (/usr/lib/nodejs/request/main.js:212:58)
npm ERR!     at Request.emit (events.js:88:20)
npm ERR!     at ClientRequest.<anonymous> (/usr/lib/nodejs/request/main.js:412:12)
npm ERR!     at ClientRequest.emit (events.js:67:17)
npm ERR!     at HTTPParser.onIncoming (http.js:1261:11)
npm ERR!     at HTTPParser.onHeadersComplete (http.js:102:31)
npm ERR! You may report this log at:
npm ERR!     <http://bugs.debian.org/npm>
npm ERR! or use
npm ERR!     reportbug --attach /npm-debug.log npm
npm ERR! 
npm ERR! System Linux 3.8.0-29-generic
npm ERR! command "node" "/usr/bin/npm" "install" "less" "nodewatch"
npm ERR! cwd /
npm ERR! node -v v0.6.12
npm ERR! npm -v 1.1.4
npm ERR! message failed to fetch from registry: less
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /npm-debug.log
npm not ok

Found another thread that explains this and offers the solution to execute

npm config set registry http://registry.npmjs.org/

However after running the above command I am getting this error:

(default)root@ckan:/# npm config set registry http://registry.npmjs.org/
(default)root@ckan:/# npm install less nodewatch
npm http GET http://registry.npmjs.org/less
npm http GET http://registry.npmjs.org/nodewatch
npm http 200 http://registry.npmjs.org/less
npm http GET http://registry.npmjs.org/less/-/less-1.6.3.tgz
npm http 200 http://registry.npmjs.org/nodewatch
npm http GET http://registry.npmjs.org/nodewatch/-/nodewatch-0.3.1.tgz
npm http 200 http://registry.npmjs.org/less/-/less-1.6.3.tgz
npm http 200 http://registry.npmjs.org/nodewatch/-/nodewatch-0.3.1.tgz
npm http GET http://registry.npmjs.org/mime
npm http GET http://registry.npmjs.org/request
npm http GET http://registry.npmjs.org/mkdirp
npm http GET http://registry.npmjs.org/clean-css
npm http GET http://registry.npmjs.org/source-map
npm http 200 http://registry.npmjs.org/request
npm http GET http://registry.npmjs.org/request/-/request-2.33.0.tgz
npm http 200 http://registry.npmjs.org/request/-/request-2.33.0.tgz
npm http 200 http://registry.npmjs.org/mime
npm http GET http://registry.npmjs.org/mime/-/mime-1.2.11.tgz
npm http 200 http://registry.npmjs.org/mkdirp
npm http 200 http://registry.npmjs.org/clean-css
npm http GET http://registry.npmjs.org/mkdirp/-/mkdirp-0.3.5.tgz
npm WARN optional dependency failed, continuing clean-css@2.0.x
npm http 200 http://registry.npmjs.org/source-map
npm http 200 http://registry.npmjs.org/mime/-/mime-1.2.11.tgz
npm http GET http://registry.npmjs.org/source-map/-/source-map-0.1.3.tgz
npm http 200 http://registry.npmjs.org/mkdirp/-/mkdirp-0.3.5.tgz
npm http 200 http://registry.npmjs.org/source-map/-/source-map-0.1.3.tgz
npm ERR! error installing less@1.6.3
npm ERR! error rolling back less@1.6.3 Error: UNKNOWN, unknown error '/node_modules/less'

npm ERR! Unsupported
npm ERR! Not compatible with your version of node/npm: request@2.33.0
npm ERR! Required: ["node >= 0.8.0"]
npm ERR! Actual:   {"npm":"1.1.4","node":"0.6.12"}
npm ERR! 
npm ERR! System Linux 3.8.0-29-generic
npm ERR! command "node" "/usr/bin/npm" "install" "less" "nodewatch"
npm ERR! cwd /
npm ERR! node -v v0.6.12
npm ERR! npm -v 1.1.4
npm ERR! code ENOTSUP
npm ERR! message Unsupported
npm ERR! errno {}
npm http GET http://registry.npmjs.org/requirejs/0.26.0
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /npm-debug.log
npm not ok

Seems like the version are incompatible or could this be the problem with node and node.js?

Cheers, Shao



标签: ckan