noob programmer here, I'm trying to get the SQLite3 on my Python installation up-to-date (I currently have version 3.6.11, whereas I need at least version 3.6.19, as that is the first version that supports foreign keys). Here's my problem, though: I have no idea how to do this. I know next to nothing about the command line, and I don't really know what files to replace (if at all) in my python install. And before anyone asks, I'm already using the latest Pysql version – it's what's not up to date. Can anyone give me some pointers, or maybe a guide on how to update this?
I'm on Mac OSX 10.5.8, working with python 2.6.
I suggest using the 'pip' command on the command line.
pip search sqlite
pip install pysqlite
I just came fresh from installing this both in Mavericks and Mountain Lion.
This SO article mentions using the build_static method, which they say retrieves that latest version of the sqlite amalgamation. For some reason it didn't work (ie it didn't seem to download it or use it)
What I ended up doing was
Downloaded pysqlite as a tarball
Downloaded latest sqlite source amalgamation
Unzipped pysqlite into its folder
Unzipped sqlite and copied that to the pysqlite folder
Opened setup.cfg and commented out all of the directives
In Terminal, went to the pysqlite folder, and then:
$ python setup.py build_static install
This compiled pysqlite using the libraries from the latest sqlite sources. And then in Python, I used it as:
import pysqlite2.dbapi2 as sqlite3
I recently installed python from source and used the following commands to install both SQLite from source and Python 2.7.13 from source.
for SQLite3 you can use the following commands
$SQLITE_INSTALL_LOCATION
$ curl -O http://www.sqlite.org/sqlite-autoconf-3070603.tar.gz
$ tar xvfz sqlite-autoconf-3070603.tar.gz
$ cd sqlite-autoconf-3070603
$ ./configure --prefix=$SQLITE_INSTALL_LOCATION --disable-static CFLAGS="-g"
$ make && make install
Then when I compiled my python I edited the setup.py in the root of the Python source
$ curl -O https://www.python.org/ftp/python/2.7.13/Python-2.7.13.tgz
$ tar xvfz Python-2.7.13.tgz
Python-2.7.13/setup.py -- add the path to your SQLite install here:
```
...
# We hunt for #define SQLITE_VERSION "n.n.n"
# We need to find >= sqlite version 3.0.8
sqlite_incdir = sqlite_libdir = None
sqlite_inc_paths = [ '/usr/include',
'/usr/include/sqlite',
'/usr/include/sqlite3',
'/usr/local/include',
'/usr/local/include/sqlite',
'/usr/local/include/sqlite3',
$SQLITE_INSTALL_LOCATION/include,
]
...
Once you've changed the setup.py in your python source finish up compiling and installing python assuming the install location is $PYTHON_INSTALL_LOCATION
$ cd Python-2.7.13
$ LD_RUN_PATH=$SQLITE_INSTALL_LOCATION/lib ./configure --prefix=$PYTHON_INSTALL_LOCATION --enable-shared --enable-unicode=ucs4
$ LD_RUN_PATH=$SQLITE_INSTALL_LOCATION/lib make
$ LD_RUN_PATH=$SQLITE_INSTALL_LOCATION/lib make install
Once you do that you should have a Python version with SQLite3 support installed at $PYTHON_INSTALL_LOCATION/bin/python
Hope this helps!
Disclaimer: I'm not a Mac User, but by common knowledge i give you
this info.
You could follow the next instructions:
Use Homebrew
As this page mention: If you need to upgrade sqlite, you could use Homebrew.
Homebrew implies an aditional "software manager". So you should know how to use it before.
Install it from the source
As this page metion:
Download the sqlite-autoconf package
Compile it and install it:
:
$ tar xvfz sqlite-autoconf-3071502.tar.gz
$ cd sqlite-autoconf-3071502
$ ./configure --prefix=/usr/local
$ make
$ make install
Either Homebrew or Source, verfy it
>>> import sqlite3
>>> sqlite3.version_info
(2, 4, 1)
>>> sqlite3.sqlite_version_info
(3, 6, 11)
>>> from pysqlite2 import dbapi2 as sqlite3
>>> sqlite3.version_info
(2, 5, 5)
>>> sqlite3.sqlite_version_info
(3, 6, 18)
Maybe you need to uninstall previous version of pysqlite. In any way, you should read this answer to understand better the sqlite/python relationship.
https://pip.pypa.io/en/latest/installing.html
python get-pip.py
python [complete path]
python c:\folder\get-pip.py
Related
I recently deleted the default python version on Fedora 31 and installed python 3.9 then made it as default, now I have multiple versions of python.
If I type: whereis python in my terminal this list appear:
python: /usr/bin/python /usr/bin/python3.9 /usr/bin/python3.7 /usr/bin/python3.9-config /usr/bin/python3.7m /usr/bin/python3.9-x86_64-config /usr/lib/python3.9 /usr/lib/python2.6 /usr/lib/python3.7 /usr/lib64/python3.9 /usr/lib64/python3.7 /usr/local/bin/python3.7m-config /usr/local/bin/python3.7 /usr/local/bin/python3.7m /usr/local/lib/python3.7 /usr/include/python3.9 /usr/include/python3.7m /usr/share/man/man1/python.1.gz /usr/src/Python-3.7.4/python
If I type pip then I get ModuleNotFoundError: No module named 'pip'
Also multiple packages are broken such as dnf, argcomplete, pip, etc.
I cannot update or install anything.
How can I solve this problem ?
Grab/Download the original python RPMs for your distro and reinstall them that way if they're not still cached under /var ....
With Python 3.9 you should use pip3...So install python3-pip.
That should do the trick
I tried many solutions and didn't work, however I ended up backing up my data and completely deleting the OS, then I downloaded the last version of fedora and restored my data on it.
thanks for your time
I ran into this unfortunate situation as well on Fedora 35. dnf, yum, and a bunch of other things broke.
I didn't manage to get Python 3.10 back through dnf, yum, or apt-get. I downloaded the rpm from https://fedora.pkgs.org/35/fedora-x86_64/python3-3.10.0-1.fc35.x86_64.rpm.html. It did require a dependency of python3-libs which I downloaded from: https://fedora.pkgs.org/35/fedora-x86_64/python3-libs-3.10.0-1.fc35.x86_64.rpm.html.
I installed python3-libs first with sudo rpm -i python3-libs-3.10.0-1.fc35.x86_64.rpm --force as there were some file writing conflicts. I ran the same command for the python3.10 rpm with the --force flag as well since there were 2 conflicts. After that, everything worked perfectly! Managed to dodge having to do a full reinstall.
using python3.3 on OS X 10.7.5
when i run
virtualenv-3.3 virtualenv/
it errors on
FileNotFoundError: [Errno 2] No such file or directory: '.../virtualenv/bin/easy_install'
after
Overwriting virtualenv/lib/python3.3/site.py with new content
Overwriting virtualenv/lib/python3.3/orig-prefix.txt with new content
Overwriting virtualenv/lib/python3.3/no-global-site-packages.txt with new content
New python executable in virtualenv/bin/python3.3
Not overwriting existing python script virtualenv/bin/python (you must use virtualenv/bin/python3.3)
Overwriting virtualenv/lib/python3.3/distutils/__init__.py with new content
File virtualenv/lib/python3.3/distutils/distutils.cfg exists with different content; not overwriting
Installing distribute...done.
Installing pip...
my system has setuptools / distribute.
why isn't virtualenv setting up easy_install?
This issue is related to having an outdated version of Pip, I think.
I got a similar error on CEntOS 6.3.
I suggest at least attempting to bootstrap a virtual environment. If it doesn't work, all you have to lose are some megabytes and a 20 minutes of your time.
What you will need:
Compiled Python3.4
Source of the latest VirtualEnv
Fortitude
Pen and paper
Something similar to the answer outlined here might work: What's the proper way to install pip, virtualenv, and distribute for Python?
In short, download the virtualenv package from source from PyPI, extract it, and cd into the directory created by the extraction.
From the documentation:
$ curl -O https://pypi.python.org/packages/source/v/virtualenv/virtualenv-X.X.tar.gz
$ tar xvfz virtualenv-X.X.tar.gz
$ cd virtualenv-X.X
Replace the X.X above with the version number. For example, cd virtualenv-X.X would, after replacing the Xs with the right version number, be cd virtualenv-13.1.2.
Then, use virtualenv.py from there, not just $ virtualenv, but $ ./virtualenv.py.
I hope that this would work much better, since pip with the latest virtualenv will include easy_install in the expected location.
I have tested this on a CEntOS 6.3 machine with a similar configuration. It works on there, but I cannot afford a copy of OS X 10.7.5.
I have installed bottle on my Ubuntu Linux server using
sudo pip install bottle
and it is installed to: /usr/local/lib/python2.7/dist-packages
But I also have Python 3.2 installed on my system, and I want to access bottle from Python 3.2. Python 3.2 does not seem to recognise that bottle is installed.
What am I doing wrong?
You'd have to separately install it for Python 3.2 (with e.g. sudo pip-3.2 install bottle).
It's currently in python2.7/dist-packages, meaning that only 2.7 is going to load it. You could try to add that to your PYTHONPATH or similar, but that will very rarely work between Python 2 and 3 because the source files aren't quite compatible. (Any C extensions are also certainly not going to work, though bottle doesn't have any of those.)
Unfortunately, although that command works, it looks like the version of bottle in pypi isn't Python 3-compatible even when installed through pip-3.2:
In [1]: import bottle
File "/Library/Frameworks/Python.framework/Versions/3.2/bin/bottle.py", line 373
except re.error, e:
^
SyntaxError: invalid syntax
The homepage claims that it works with 3.x, but I got that error installing with both pip and easy_install. The latest development version, which is just a single file linked from the homepage, seems to work, though.
You are not doing anything wrong. Pip uses the /usr/bin/python by default and only installs there.
Unless you want to setup virtualenv-s, you probably best copy the current pip to pip3.2 and edit that to call python 3.2:
sudo -s -H
p=$(which pip)
cat $p | sed "1s|/usr/bin/python|$(which python3.2)|" > $p"3.2"
chmod 755 $p"3.2"
exit
You now have a pip3.2 that will install bottle so python3.2 can use it. If you get an error running pip3.2 about not finding pkg_resources look at No module named pkg_resources
I'll answer this myself. Turns out the latest release version of pip does not include pip-3.2. You need to download the development version and use that, which includes pip-3.2.
Just download it manually from offsite. It is just one file.
Place it into the lib/site-packages folder and give the file proper rights.
I'm getting errors when running
$ brew install postgresql
==> Downloading http://ftp.postgresql.org/pub/source/v9.1.2/postgresql-9.1.2.tar.bz2
File already downloaded in /Users/neil/Library/Caches/Homebrew
Warning: Detected a framework Python that does not have 64-bit support in:
/Library/Frameworks/Python.framework/Versions/Current/Python
e configure script seems to prefer this version of Python over any others,
you may experience linker problems as described in:
http://osdir.com/ml/pgsql-general/2009-09/msg00160.html
fix this issue, you may need to either delete the version of Python
own above, or move it out of the way before brewing PostgreSQL.
te that a framework Python in /Library/Frameworks/Python.framework is
e "MacPython" version, and not the system-provided version which is in:
/System/Library/Frameworks/Python.framework
==> ./configure --disable-debug --prefix=/usr/local/Cellar/postgresql/9.1.2 --datadir=/usr/local/Cellar/postgresql/9.1.2/shar
^C
Here's where python is located.
$ which python
/usr/local/bin/python
I modified my ~/.zshrc PATH from
export PATH=/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin
to
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin
And although I'm getting python 64-bit errors, my version of python is 64-bit according to this SO post:
$ python -c 'import struct;print( 8 * struct.calcsize("P"))'
64
The problem pointed out in the referenced mailing list post is that the configure step isn't impacted by the PATH here. There's a whole other mechanism used to find things to link against; see Where do I set DYLD_LIBRARY_PATH on Mac OS X for a quick intro. You could try the suggested workaround given by the brew script--rename /Library/Frameworks/Python.framework/Versions/Current/Python to something else to get it out of the linker's search path, repeat the brew install, then put it back.
If you don't need Python bindings in your PostgreSQL, you can also just install it without Python bindings using brew install postgresql --no-python.
This command is installing the server, not the python bindings. Is that what you want? There is a installer for osx that will install the server for you.
Once you have done that, you can install the psycopg2 bindings directly from source.
I'm working with OpenERP and a module named report_openoffice. This module needs the package python-uno installed. The problem is that i have 2 versions of python(2.6 and 2.7). When I install the package, Python2.7 can use the package python-uno but python2.6 can't. I need to use it in python2.6. Is there a way to install this package for python 2.6?
PS: I'm on Ubuntu 11.04
Thank you very much
I soft linked the uno.py and unohelper.py from 2.7 into 2.6 and that seems to work.
As root do (or with sudo):
$> cd /usr/lib/python2.6/dist-packages
$> ln -s /usr/lib/python2.7/dist-packages/uno.py
$> ln -s /usr/lib/python2.7/dist-packages/unohelper.py
python-uno is often used to drive OpenOffice/LibreOffice. However, if you just want to create reports in odt or pdf files, you can use PyQt4
A simple example to show how to write to an odt file:
>>>from pyqt4 import QtGui
# Create a document object
>>>doc = QtGui.QTextDocument()
# Create a cursor pointing to the beginning of the document
>>>cursor = QtGui.QTextCursor(doc)
# Insert some text
>>>cursor.insertText('Hello world')
# Create a writer to save the document
>>>writer = QtGui.QTextDocumentWriter()
>>>writer.supportedDocumentFormats()
[PyQt4.QtCore.QByteArray(b'HTML'), PyQt4.QtCore.QByteArray(b'ODF'), PyQt4.QtCore.QByteArray(b'plaintext')]
>>>odf_format = writer.supportedDocumentFormats()[1]
>>>writer.setFormat(odf_format)
>>>writer.setFileName('hello_world.odt')
>>>writer.write(doc) # Return True if successful
True
QTextCursor also can insert tables, frames, blocks, images. More information. More information at:
http://qt-project.org/doc/qt-4.8/qtextcursor.html
uno package install in python 2.7, then run following commands:
sudo apt-get install libreoffice python-genshi python-cairo python-lxml python-setuptools
sudo apt-get install libreoffice-script-provider-python
easy_install uno