d844 How do I get Python virtuelenv and pysqlite to work? - The FreeBSD Forums
The FreeBSD Forums  

Go Back   The FreeBSD Forums > Development > Userland Programming & Scripting

Userland Programming & Scripting C, Shell, Perl, Sed & Awk

Reply
 
Thread Tools Display Modes
  #1  
Old July 21st, 2010, 11:52
olav's Avatar
olav olav is offline
Member
 
Join Date: Apr 2010
Location: Norway, Stavanger
Posts: 344
Thanks: 27
Thanked 23 Times in 22 Posts
Default How do I get Python virtuelenv and pysqlite to work?

I'm currently playing a bit with the Pylons Python Web Framework and is trying to get it to work with Sqlalchemy and Sqlite.

I have installed py-pysqlite23, py-sqlite3 and python2.6 from ports.

When I'm not in a virtuelenv mode the command
python -c 'import pysqlite2'
works fine.

But if I create a virtualenv with --no-site-packages
I get this
Code:
(zbadminenv)[olav@olbsd ~/zbadmin]$ python -c 'import pysqlite2'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named pysqlite2
If I try to install it with easy_install I get this error message
Code:
(zbadminenv)[olav@olbsd ~/zbadmin]$ easy_install pysqlite                                                                             
Searching for pysqlite                                                                                                                
Reading http://www.pylonshq.com/download/                                                                                             
Best match: pysqlite 2.5.6                                                                                                            
Downloading http://cdn.pylonshq.com/download/1.0/pysqlite-2.5.6.tar.gz                                                                
Processing pysqlite-2.5.6.tar.gz                                                                                                      
Running pysqlite-2.5.6/setup.py -q bdist_egg --dist-dir /tmp/easy_install-mrRfW0/pysqlite-2.5.6/egg-dist-tmp-E2BzUt                   
In file included from src/module.c:24:                                                                                                
src/connection.h:33:21: error: sqlite3.h: No such file or directory                                                                   
In file included from src/module.c:24:                                                                                                
src/connection.h:38: error: expected specifier-qualifier-list before 'sqlite3'                                                        
In file included from src/module.c:25:                                                                                                
src/statement.h:37: error: expected specifier-qualifier-list before 'sqlite3'                                                         
src/module.c:265: error: 'SQLITE_OK' undeclared here (not in a function)                                                              
src/module.c:266: error: 'SQLITE_DENY' undeclared here (not in a function)
src/module.c:267: error: 'SQLITE_IGNORE' undeclared here (not in a function)
src/module.c:268: error: 'SQLITE_CREATE_INDEX' undeclared here (not in a function)
src/module.c:269: error: 'SQLITE_CREATE_TABLE' undeclared here (not in a function)
src/module.c:270: error: 'SQLITE_CREATE_TEMP_INDEX' undeclared here (not in a function)
src/module.c:271: error: 'SQLITE_CREATE_TEMP_TABLE' undeclared here (not in a function)
src/module.c:272: error: 'SQLITE_CREATE_TEMP_TRIGGER' undeclared here (not in a function)
src/module.c:273: error: 'SQLITE_CREATE_TEMP_VIEW' undeclared here (not in a function)
src/module.c:274: error: 'SQLITE_CREATE_TRIGGER' undeclared here (not in a function)
src/module.c:275: error: 'SQLITE_CREATE_VIEW' undeclared here (not in a function)
src/module.c:276: error: 'SQLITE_DELETE' undeclared here (not in a function)
src/module.c:277: error: 'SQLITE_DROP_INDEX' undeclared here (not in a function)
src/module.c:278: error: 'SQLITE_DROP_TABLE' undeclared here (not in a function)
src/module.c:279: error: 'SQLITE_DROP_TEMP_INDEX' undeclared here (not in a function)
src/module.c:280: error: 'SQLITE_DROP_TEMP_TABLE' undeclared here (not in a function)
src/module.c:281: error: 'SQLITE_DROP_TEMP_TRIGGER' undeclared here (not in a function)
src/module.c:282: error: 'SQLITE_DROP_TEMP_VIEW' undeclared here (not in a function)
src/module.c:283: error: 'SQLITE_DROP_TRIGGER' undeclared here (not in a function)
src/module.c:284: error: 'SQLITE_DROP_VIEW' undeclared here (not in a function)
src/module.c:285: error: 'SQLITE_INSERT' undeclared here (not in a function)
src/module.c:286: error: 'SQLITE_PRAGMA' undeclared here (not in a function)
src/module.c:287: error: 'SQLITE_READ' undeclared here (not in a function)
src/module.c:288: error: 'SQLITE_SELECT' undeclared here (not in a function)
src/module.c:289: error: 'SQLITE_TRANSACTION' undeclared here (not in a function)
src/module.c:290: error: 'SQLITE_UPDATE' undeclared here (not in a function)
src/module.c:291: error: 'SQLITE_ATTACH' undeclared here (not in a function)
src/module.c:292: error: 'SQLITE_DETACH' undeclared here (not in a function)
src/module.c: In function 'init_sqlite':
src/module.c:419: warning: passing argument 1 of 'PyString_FromString' makes pointer from integer without a cast
error: Setup script exited with error: command 'cc' failed with exit status 1
Is it possible to fix this?
Reply With Quote
  #2  
Old July 21st, 2010, 12:04
fairy fairy is offline
Banned
 
Join Date: Jun 2010
Posts: 34
Thanks: 4,294,967,295
Thanked 4 Times in 4 Posts
Default

You didn't state why you need --no-site-packages that effectively disables py-sqlite*. Pretty much any python port installs into PYTHON_SITELIBDIR (i.e. /usr/local/lib/python2.6/site-packages).
Reply With Quote
  #3  
Old July 21st, 2010, 12:21
olav's Avatar
olav olav is offline
Member
 
Join Date: Apr 2010
Location: Norway, Stavanger
Posts: 344
Thanks: 27
Thanked 23 Times in 22 Posts
Default

I want to isolate the project as much as possible, I want to make it as easy as possible to move to another system, upgrade a system and so on. I've been involved with enough of Python projects with library conflicts
Reply With Quote
  #4  
Old July 21st, 2010, 12:35
roddierod's Avatar
roddierod roddierod is offline
Member
 
Join Date: Nov 2008
Location: On my Slingerlands!
Posts: 638
Thanks: 29
Thanked 72 Times in 62 Posts
Default

site-packages is a pretty standard place to put packages, if the packages are in there then you'll start running into library conflicts.

I've written python apps that run on windows, freebsd & linux and always use site-packages without problem.
Reply With Quote
  #5  
Old July 9th, 2011, 10:07
puria puria is offline
Junior Member
 
Join Date: Jul 2011
Posts: 1
Thanks: 0
Thanked 2 Times in 1 Post
Default Same problem on FreeBSD 8.2

Almost a year after, same problem here. Seems that since the sqlite3 is in a seperated module, the pythonists freebsd guys just made e little mistake. the _sqlite3.so lib is under "site-packages" system wide that is sad

So first of all you need to install /usr/ports/databases/py-sqlite3 . Then you can fix your virtualenv --no-site-packages by link in you freshly create virtualenv as this:

Code:
$ virtualenv --no-site-packages your_virtualenv_name
$ ln -s /usr/local/lib/python2.x/site-packages/_sqlite3.so !$/lib/python2.x/
for me is python2.6 but be aware to change your right python version =)
Reply With Quote
The Following 2 Users Say Thank You to puria For This Useful Post:
Crooksey (August 9th, 2011), olav (July 10th, 2011)
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Use a different Python version as default kamikaze Howtos & FAQs (Moderated) 2 May 12th, 2012 07:04
[Solved] there are 2 versions of python xwwu Installation and Maintenance of FreeBSD Ports or Packages 2 May 18th, 2010 03:55
[Solved] Issue upgrading Python daemonSlayer Installation and Maintenance of FreeBSD Ports or Packages 8 March 5th, 2010 16:05
GIMP -> Python 2.5 vs 2.6 Eponasoft Installation and Maintenance of FreeBSD Ports or Packages 1 January 22nd, 2010 00:58
Python Ports dchappelle Installation and Maintenance of FreeBSD Ports or Packages 7 January 10th, 2009 08:45


All times are GMT +1. The time now is 02:51.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
The mark FreeBSD is a registered trademark of The FreeBSD Foundation and is used by The FreeBSD Project with the permission of The FreeBSD Foundation.
Web protection and acceleration provided by CloudFlare
0