From owner-freebsd-questions@freebsd.org Wed Jun 15 12:57:29 2016 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B136BA1DB2C; Wed, 15 Jun 2016 12:57:29 +0000 (UTC) (envelope-from dweimer@dweimer.net) Received: from webmail.dweimer.net (24-240-198-188.static.stls.mo.charter.com [24.240.198.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 90A9B1C85; Wed, 15 Jun 2016 12:57:28 +0000 (UTC) (envelope-from dweimer@dweimer.net) Received: from webmail.dweimer.local (localhost [10.9.5.2]) by webmail.dweimer.net (8.15.2/8.15.2) with ESMTPS id u5FCudK5036081 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 15 Jun 2016 07:56:40 -0500 (CDT) (envelope-from dweimer@dweimer.net) Received: (from www@localhost) by webmail.dweimer.local (8.15.2/8.15.2/Submit) id u5FCudX7036080; Wed, 15 Jun 2016 07:56:39 -0500 (CDT) (envelope-from dweimer@dweimer.net) X-Authentication-Warning: webmail.dweimer.local: www set sender to dweimer@dweimer.net using -f To: Nan Xiao Subject: Re: How to use sqlite3 in python on FreeBSD 10.3? MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 15 Jun 2016 07:56:39 -0500 From: "Dean E. Weimer" Cc: freebsd-questions , owner-freebsd-questions@freebsd.org Organization: dweimer.net Reply-To: dweimer@dweimer.net Mail-Reply-To: dweimer@dweimer.net In-Reply-To: <2016061518322497404919@chinadtrace.org> References: <2016061518322497404919@chinadtrace.org> Message-ID: X-Sender: dweimer@dweimer.net User-Agent: Roundcube Webmail/1.2.0 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Jun 2016 12:57:29 -0000 On 2016-06-15 5:32 am, Nan Xiao wrote: > Hi all, > > Greetings from me! I am a newbie of FreeBSD, and want to use sqlite3 > in python on my FreeBSD 10.3. After installing python, it prompts I > should install the following additional packages: > > ...... > =========================================================================== > Note that some standard Python modules are provided as separate ports > as they require additional dependencies. They are available as: > bsddb databases/py-bsddb > gdbm databases/py-gdbm > sqlite3 databases/py-sqlite3 > tkinter x11-toolkits/py-tkinter > =========================================================================== > From this post, it seems after installing above 4 packages, the > sqlite3 should be able to work. But "impore sqlite3" still reports > following errors: > >>>> import sqlite3 > Traceback (most recent call last): > File "", line 1, in > File "/usr/local/lib/python2.7/sqlite3/__init__.py", line 24, in > > from dbapi2 import * > File "/usr/local/lib/python2.7/sqlite3/dbapi2.py", line 28, in > > from _sqlite3 import * > ImportError: No module named _sqlite3 > > Could anyone help on this issue? Thanks very much in advance! > > Have a nice day! > > P.S., I also submit this issue on SO, but unfortunately, I can't get > any help from there, so I repost the question here, thanks! > use "pkg info | grep py" and verify that the packages did install correctly, from one of my systems running Python with py-sqlite3, it works fine. I am running WeeWX on this system which even though I am using mySQL for most of the data, it still has some dependency on sqlite3, so not only does it import, but I have applications using py-sqlite3. pkg info | grep py py27-Babel-2.3.4 Collection of tools for internationalizing Python applications py27-Jinja2-2.8 Fast and easy to use stand-alone template engine py27-MarkupSafe-0.23 Implements XML/HTML/XHTML Markup safe string for Python py27-MySQLdb56-1.2.5 Access a MySQL database through Python py27-alabaster-0.7.6 Modified Kr Sphinx theme py27-cheetah-2.4.4_1 HTML template engine for Python py27-configobj-5.0.6_1 Simple but powerful config file reader and writer py27-dnspython-1.12.0 DNS toolkit for Python py27-docutils-0.12 Python Documentation Utilities py27-imagesize-0.7.1 Python image size library py27-markdown-2.6.5 Python implementation of Markdown py27-pillow-3.1.1_1 Fork of the Python Imaging Library (PIL) py27-pip-8.0.2 Tool for installing and managing Python packages py27-pycurl-7.21.5 Python interface to libcurl py27-pygments-2.1.3 Syntax highlighter written in Python py27-pystemmer-1.3.0_1 Snowball Stemming Algorithms for Information Retrieval py27-pytz-2016.4,1 World Timezone Definitions for Python py27-setuptools27-20.0 Python packages installer py27-six-1.10.0 Python 2 and 3 compatibility utilities py27-snowballstemmer-1.2.0_1 Snowball stemming library collection for Python py27-sphinx-1.4.1 Python documentation generator py27-sphinx_rtd_theme-0.1.9 Mobile-friendly py-sphinx theme py27-sqlite3-2.7.11_7 Standard Python binding to the SQLite3 library (Python 2.7) py27-tkinter-2.7.11_6 Python bindings to the Tk widget set (Python 2.7) py27-usb-1.0.0b1_1 Python wrapper around libusb pyephem-3.7.6.0,1 Scientific-grade astronomical computations for Python python-2.7_2,2 The "meta-port" for the default version of Python interpreter python2-2_3 The "meta-port" for version 2 of the Python interpreter python27-2.7.11_2 Interpreted object-oriented programming language python3-3_3 The "meta-port" for version 3 of the Python interpreter python34-3.4.4_2 Interpreted object-oriented programming language root@weewx:/ # python Python 2.7.11 (default, Jun 10 2016, 09:38:24) [GCC 4.2.1 Compatible FreeBSD Clang 3.4.1 (tags/RELEASE_34/dot1-final 208032)] on freebsd10 Type "help", "copyright", "credits" or "license" for more information. >>> import sqlite3 >>> make sure that the py27_sqlite3 or py34-sqlite3 depending on which you are trying to use is installed. I have Python 2.7 set as system default do to some requirements on the software. But also have Python 3.4 installed for some custom system maintenance scripts I have written, those fortunately don't require any other python dependencies so it seems to work OK having both installed. -- Thanks, Dean E. Weimer http://www.dweimer.net/