You are not logged in.

#1 2006-01-05 14:33:33

Komodo
Member
From: Oxford, UK
Registered: 2005-11-03
Posts: 674

Python problem

There's this great personal wiki program called WikidPad that I've started using for organisational purposes.

However, I have to run the win32 version in wine, because I can't get the linux version to work.

I definitely have the dependencies installed, but when I run the program, I get this error message:

dave@kaminoitte:/var/abs/local/wikidPad$ python WikidPad.py 
Traceback (most recent call last):
  File "WikidPad.py", line 22, in ?
    from pwiki.PersonalWikiFrame import PersonalWikiFrame
  File "/usr/lib/python2.4/site-packages/pwiki/PersonalWikiFrame.py", line 12, in ?
    import Configuration
  File "/usr/lib/python2.4/site-packages/pwiki/Configuration.py", line 22, in ?
    from StringOps import utf8Enc, utf8Dec, mbcsDec, strToBool
  File "/usr/lib/python2.4/site-packages/pwiki/StringOps.py", line 66, in ?
    import encodings.mbcs
  File "/usr/lib/python2.4/encodings/mbcs.py", line 14, in ?
    class Codec(codecs.Codec):
  File "/usr/lib/python2.4/encodings/mbcs.py", line 18, in Codec
    encode = codecs.mbcs_encode
AttributeError: 'module' object has no attribute 'mbcs_encode'

Would someone more experienced with python care to hazard a guess as to what's going on?


.oO Komodo Dave Oo.

Offline

#2 2006-01-05 19:08:42

TPJ
Member
From: Gliwice, Poland
Registered: 2005-12-21
Posts: 33

Re: Python problem

The answer to the question "what's going on?" is quite simple: someone tries to use something (probably a function) called codecs.mbcs_encode, that just doesn't exist in the codecs module. That's why Python prints out this message.

I've just checked it on my Python (2.4.1): there's no codecs.mbcs_encode in the codecs module. (You can check it for yourself; just do:

$ python
>>> import codecs
>>> dir(codecs)

and try to find anything called mbcs_encode.)

The most important questions here are "what is this codecs.mbcs_encode, what it should be, and why it's not there?". Well... I didn't know anything about it, so I took a look at the Python's documentation. And here's what I've found there:

mbcs      dbcs      Unicode string      Windows only: Encode operand according to the ANSI codepage (CP_ACP)

So I think that this mbcs is a Windows-specific feature, that isn't available in Python run on Linux system. Therefore it's impossible to run this program on Linux.

Offline

#3 2006-01-05 20:44:28

Komodo
Member
From: Oxford, UK
Registered: 2005-11-03
Posts: 674

Re: Python problem

I have to say TPJ, if there were awards for 'post of the month', I'd nominate you for one big_smile

Seriously, not only did you answer my question, but you answered it incredibly clearly, and in sufficient detail that in the future I can rectify similar problems myself.

Many thanks, your response is very much appreciated =o)


.oO Komodo Dave Oo.

Offline

#4 2006-01-05 21:30:53

arooaroo
Member
From: London, UK
Registered: 2005-01-13
Posts: 1,268
Website

Re: Python problem

Yeah, something I've started getting used to is that I can't rely on modules being cross platform. In some ways, it's great that there are modules that utilise OS specific functionality, but it does mean you have to pay attention to what works on what.

The codecs doc page with information about which encodings are possible (and on which platform) can be found here.

If you look at the module index you'll see just how many are OS specific.

Offline

#5 2006-01-05 22:08:19

Komodo
Member
From: Oxford, UK
Registered: 2005-11-03
Posts: 674

Re: Python problem

arooaroo wrote:

If you look at the module index you'll see just how many are OS specific.

Jesus, WAY more than I thought :?

Loads of Mac ones in particular...


.oO Komodo Dave Oo.

Offline

#6 2006-01-06 15:49:02

Komodo
Member
From: Oxford, UK
Registered: 2005-11-03
Posts: 674

Re: Python problem

Ok, I got round the original problem by editing one of the python files.

Now there's a new issue; despite me having installed sqlite3, the python script doesn't seem to acknowledge it:

python WikidPad.py 
Traceback (most recent call last):
  File "WikidPad.py", line 20, in ?
    from pwiki.PersonalWikiFrame import PersonalWikiFrame
  File "/var/abs/local/wikidPad/lib/pwiki/PersonalWikiFrame.py", line 15, in ?
    from WikiData import *
  File "/var/abs/local/wikidPad/lib/pwiki/WikiData.py", line 26, in ?
    import sqlite3api as sqlite
  File "/var/abs/local/wikidPad/lib/pwiki/sqlite3api.py", line 8, in ?
    import SqliteThin3
  File "/var/abs/local/wikidPad/lib/pwiki/SqliteThin3.py", line 84, in ?
    _dll = cdll.sqlite3
  File "/usr/lib/python2.4/site-packages/ctypes/__init__.py", line 407, in __getattr__
    dll = self._dlltype(name)
  File "/usr/lib/python2.4/site-packages/ctypes/__init__.py", line 319, in __init__
    self._handle = _LoadLibrary(self._name)
OSError: sqlite3: cannot open shared object file: No such file or directory

Any suggestions?


.oO Komodo Dave Oo.

Offline

#7 2006-01-06 20:42:47

Snowman
Developer/Forum Fellow
From: Montreal, Canada
Registered: 2004-08-20
Posts: 5,212

Re: Python problem

Just a guess: Maybe you need  python-pysqlite from extra repo.

Offline

#8 2006-01-06 20:51:10

Komodo
Member
From: Oxford, UK
Registered: 2005-11-03
Posts: 674

Re: Python problem

Snowman wrote:

Just a guess: Maybe you need  python-pysqlite from extra repo.

I thought the same Snowman, but I installed that alongside sqlite3, and still no joy =o(


.oO Komodo Dave Oo.

Offline

#9 2006-01-06 21:02:04

Snowman
Developer/Forum Fellow
From: Montreal, Canada
Registered: 2004-08-20
Posts: 5,212

Re: Python problem

There are also some pysqlite* packages in AUR. You could check them out too.

[EDIT]
One of them is the same as python-pysqlite. You might want to check the others.

Offline

#10 2006-01-06 21:40:15

Komodo
Member
From: Oxford, UK
Registered: 2005-11-03
Posts: 674

Re: Python problem

Thank you for the info Snowman, I'll go try out the others now smile


.oO Komodo Dave Oo.

Offline

#11 2006-01-06 23:36:22

Komodo
Member
From: Oxford, UK
Registered: 2005-11-03
Posts: 674

Re: Python problem

Still no joy...

This is really odd; I've got everything I need I think... yet why does it not acknowledge SQlite3 even though it's installed?


.oO Komodo Dave Oo.

Offline

#12 2006-01-06 23:39:09

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: Python problem

is it possible that its using the wrong version of sqllite? An example is in java requiring Java 1.5, sometimes your PATH is such that it finds Java 1.4 first and you get really confused.....

Ok, that only happens to windows users, but you get my point... just a thought.

Dusty

Offline

#13 2006-01-06 23:50:25

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: Python problem

There are 3 versions of pysqlite in the aur (well, one is in extra) - pysqlite2 is for sqlite3, pysqlite is for sqlite2, and pysqlite-legacy is v1.0.6 for sqlite2, but is required by supybot (because the head dev doesn't want to upgrade his code)

Offline

#14 2006-01-06 23:57:38

Komodo
Member
From: Oxford, UK
Registered: 2005-11-03
Posts: 674

Re: Python problem

Dusty wrote:

is it possible that its using the wrong version of sqllite? An example is in java requiring Java 1.5, sometimes your PATH is such that it finds Java 1.4 first and you get really confused.....

I know what you mean Dusty, but I don't think I have multiple versions of sqlite, sadly:

local/libgda 1.2.2-3
    data abstraction layer; with mysql, pgsql, ldap, xml, sqlite providers
local/python-pysqlite 2.0.5-2
    A Python DB-API 2.0 interface for the SQLite embedded relational database engine
local/sqlite3 3.2.8-1
    A C library that implements an SQL database engine
phrakture wrote:

There are 3 versions of pysqlite in the aur (well, one is in extra) - pysqlite2 is for sqlite3, pysqlite is for sqlite2, and pysqlite-legacy is v1.0.6 for sqlite2, but is required by supybot (because the head dev doesn't want to upgrade his code)

Roger that; I have got the correct packages installed then, neh?

Hmmph....

I'm running WikidPad in wine atm by adding mscrvt.dll and python24.dll in winecfg, but it's irritating to use a win32 version of software when you know it *should* work in 'nux.  :evil:


.oO Komodo Dave Oo.

Offline

Board footer

Powered by FluxBB