Reputation: 1846
I'm getting the following error:
from pysqlite2 import dbapi2 as sqlite ImportError: No module named pysqlite2
I tried to install it:
python -mpip install pysqlite2
I get this error:
Could not find a version that satisfies the requirement pysqlite2 (from versio ns: ) No matching distribution found for pysqlite2
i read this: ImportError: No module named pysqlite2
but the solution there is to change the code which I'm not allowed to do. This code is working on one station we simply want it to work in another station.
What should I do (I should note I'm using Windows 7
)?
Upvotes: 0
Views: 2272
Reputation: 51807
The right answer is that your code is old and it needs to be updated. Do that. Branch or fork the repository, do whatever it takes to get working, modern code.
If you are unable or unwilling to do such things for contrived reasons you have a few options, ranging from the least horrible to the most horrible:
Create your own pysqlite2
module, that is a wrapper around sqlite3. You'll probably only have to adapt a few functions, and you may not even have to do that. It might just look like this:
import sqlite3
connect = sqlite3.connect
I'm not sure what features the code uses. But this would work, if you do it right.
Change the original code through monkeypatching. This is gnarly and error prone, and difficult to get right.
Change the original code by doing some AST hacks. This is difficult and hackish. You can do it. But you shouldn't. You really really shouldn't.
Just do the right thing, but if you can't, it is possible, with possibly a lot of effort, to do the wrong thing and make it work anyway. Just make sure to leave loads of comments apologizing profusely to the poor developer who comes after you and has to maintain this ball of duct tape and baling wire.
You never know, they may be a homicidal psychopath who knows where you live. (I know I'd get a little homicidal if I had to maintain code like this)
Upvotes: 3