I have compiled SQLite3 3.8.6 and installed it to ${HOME}/opt with:
LDFLAGS="-L${HOME}/opt/lib" CFLAGS="-L${HOME}/opt/include" ./configure --prefix=$HOME/opt
make && make install
I am now trying to compile Python 3.4.2 to use this version instead of the version installed for the entire system. I do not have root access on this system. To compile Python, I am using:
LDFLAGS="-L${HOME}/opt/lib" CFLAGS="-L${HOME}/opt/include" ./configure --prefix=$HOME/opt
make && make install
I was able to compile Python 3.3.5 with my newer version if SQLite3, but these same steps don't seem to work for me for 3.4.2.
How can I compile Python 3.4.2 to include my version of SQLite 3.8.6 which is located in ${HOME}/opt?
Thanks.
EDIT: It compiles & installs OK except for the fact that is using the older, system version of sqlite3 instead of the version that I compiled & installed myself.
There is also the option of pre-linking your custom Python build with your own-built sqlite3. (I had the same issue: the custom python was using the system-provided sqlite3, completely ignoring the sqlite3 I built).
Prefix your configure and make commands with:
LD_RUN_PATH=$HOME/opt/lib configure LDFLAGS="-L$HOME/opt/lib" CPPFLAGS="-I$HOME/opt/include" …
LD_RUN_PATH=$HOME/opt/lib make
so that the built python3 by default is linked to your sqlite3.
This worked for me.
import platform,sqlite3
print("Oper Sys : %s %s" % (platform.system(), platform.release()))
print("Platform : %s %s" % (platform.python_implementation(),platform.python_version()))
print("SQLite : %s" % (sqlite3.sqlite_version))
When I run this code, the output contains the system's version of sqlite3:
Oper Sys : Linux 3.2.0-4-amd64
Platform : CPython 3.4.2
SQLite : 3.7.13
After installing sqlite v3.8.6 under ${HOME}/opt{include,lib} and setting this in my .bashrc:
export LD_LIBRARY_PATH="${HOME}/opt/lib"
I get my desired result:
Oper Sys : Linux 3.2.0-4-amd64
Platform : CPython 3.4.2
SQLite : 3.8.6
Notice the SQLite version changes from 3.7.13 to 3.8.6
Hi for me helped this:
cd /tmp
wget https://www.sqlite.org/2019/sqlite-autoconf-3280000.tar.gz
tar xvf sqlite-autoconf-3280000.tar.gz
mv /usr/bin/sqlite3 /usr/bin/sqlite3.7
cp /tmp/sqlite-autoconf-3280000/sqlite3 /usr/bin/sqlite3
cp /tmp/sqlite-autoconf-3280000/.libs/libsqlite3.so.0.8.6 /usr/lib64/libsqlite3.so.0.8.6
cp /tmp/sqlite-autoconf-3280000/.libs/libsqlite3.so.0 /usr/lib64/libsqlite3.so.0
Related
How do I select the Python version when building a RPM from a .spec file on Fedora 35?
The CentOS/RHEL documentation says
Configure the particular Python 3 version in the BuildRequires of the SPEC file to python36-rpm-macros, python38-rpm-macros, or python39-rpm-macros.
CHAPTER 40. PACKAGING PYTHON 3 RPMS
Fedora only has a python3.9 package and python3-rpm-macros package.
How can I set the Python version? How can I make this selection portable between Fedora, RHEL, and other Enterprise Linux flavors?
Attempt at solution
%define __python3 /usr/bin/python3.9
%{?fedora:BuildRequires: python3.9}
%{?rhel:BuildRequires: python39-devel}
Is this correct?
%global python_minimum_version 3.9.0
%{?fedora:Requires: python3 >= %{python_minimum_version}}
%{?rhel:Requires: python39 >= %{python_minimum_version}}
%{?fedora:BuildRequires: python3-devel >= %{python_minimum_version}}
# yes, I do crazy things in the rpm build, and I need pip
%{?fedora:BuildRequires: python3-pip}
# without wheel the installed files lack `python_qpid_proton-0.37.0.dist-info`
%{?fedora:BuildRequires: python3-wheel}
%{?rhel:BuildRequires: python39-devel >= %{python_minimum_version}}
%{?rhel:BuildRequires: python39-pip}
%{?rhel:BuildRequires: python39-wheel}
%{?rhel:BuildRequires: python39-rpm-macros}
This seems to produce a package that behaves well on both Fedora and CentOS Stream 8.
On Fedora, latest Python is used, and on CentOS I get Python 3.9 and the #! lines in script get rewritten to use that Python 3.9 automatically.
I consider this a success.
I'm using CocoTB to test my HDL design, but as I understand, it's possible to use it with python2.7 or python3.
In setup.py config file I can see that both are supported :
[...]
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
[...]
In endian_swapper test (examples/endian_swapper/tests/test_endian_swapper.py), if I modify a test script to see which version is used :
#cocotb.test()
def wavedrom_test(dut):
"""
Generate a JSON wavedrom diagram of a trace and save it to wavedrom.json
"""
print("Python version used {}".format(sys.version_info))
I can see that python2.7 is used when I launch test with «make» command :
Python version used sys.version_info(major=2, minor=7, micro=9, releaselevel='final', serial=0)
My python3 executable is named ... python3 in fact (debian). Is there a canonical way to force cocotb to use python3 instead of python2 ?
try updating the PATH variable. worked for me.
when cocotb looks for python, it looks for it at the folders that are listed at the PATH variable.
let say that your python3 full path is at/usr/bin/python3
(you can find python3 full path by which python3)
i also added here link to new place in case both python2 and python3 are at the same folder...
> python -V
Python 2.7.17
> ln -s /usr/bin/python3 /home/$USER/python
> export PATH="/home/$USER:$PATH"
> python -V
Python 3.6.9
I found a proper way to do it.
First download the last version of python on the official website :
$ wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tar.xz
Then unflat it and configure it with the option --enable-shared
$ tar -Jxvf Python-3.7.4.tar.xz
$ cd Python-3.7.4
$ ./configure --enable-shared
$ make
$ sudo make install
Once installed go to your cocotb test directory then install virtual environment :
$ export LD_LIBRARY_PATH=/usr/local/lib
$ virtualenv --python=/usr/local/bin/python3.7 envp37
$ source envp37/bin/activate
$ python -m pip install cocotb
Then you can launch your cocotb test environment with traditional make :
$ make
Dectivate the python environment with :
$ deactivate
I found solutions on linuxconfig.org, thanks to themperek. But it's not exactly what I want.
The alias solution doesn't work for me. The update-alternative works but only with «official» python3 installed on debian. I can't use an alternative (3.7) manually installed.
$ sudo update-alternatives --config python
There are 3 choices for the alternative python (providing /usr/bin/python).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/bin/python3.7 2 auto mode
1 /usr/bin/python2.7 0 manual mode
2 /usr/bin/python3.4 1 manual mode
* 3 /usr/bin/python3.7 2 manual mode
Press enter to keep the current choice[*], or type selection number: 3
$ make clean;make
0.00ns INFO Running on Icarus Verilog version 11.0 (devel)
0.00ns INFO Python interpreter initialised and cocotb loaded!
0.00ns INFO Running tests with Cocotb v1.0.1 from /opt/cocotb
0.00ns INFO Seeding Python random module with 1554105931
0.00ns INFO Found test test_ttl.ttl_test
0.00ns INFO Running test 1/1: ttl_test
0.00ns INFO Starting test: "ttl_test"
Description: simple ttl test function
[...]
3.4.2 (default, Feb 7 2019, 06:11:23)
[...]
When i Install Cassandra 3.11X and Python 2.7.X in Debian 8.8, the Cqlsh does not start.
I get the following error.
debian#vm-184:/opt/apache-cassandra-3.10/bin$ ./cqlsh
Python Cassandra driver not installed, or not on PYTHONPATH.
You might try "pip install cassandra-driver".
Python: /usr/local/bin/python
Module load path: ['/opt/apache-cassandra-3.10/bin/../lib/six-1.7.3-py2.py3-none-any.zip', '/opt/apache-cassandra-3.10/bin/../lib/futures-2.1.6-py2.py3-none-any.zip', '/opt/apache-cassandra-3.10/bin/../lib/cassandra-driver-internal-only-3.7.0.post0-2481531.zip/cassandra-driver-3.7.0.post0-2481531', '/opt/apache-cassandra-3.10/bin', '/usr/local/lib/python27.zip', '/usr/local/lib/python2.7', '/usr/local/lib/python2.7/plat-linux2', '/usr/local/lib/python2.7/lib-tk', '/usr/local/lib/python2.7/lib-old', '/usr/local/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/site-packages']
Error: can't decompress data; zlib not available
How do we resolve this
On RedHat 7x - Install the following packages:
# yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel
Then...
# vi .../Python-2.7.13/Modules/Setup
uncomment the line:
...
zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz
AND (re-)compile python source:
# cd .../Python-2.7.13/Modules/
# ./configure
# make
# make install
Error: can't decompress data; zlib not available
Is the zlib library install?
please install zlib first.
This issue generally comes when your machine has Python 2.6 or below.
Check the answer over here cassandra 2.2 CQl Shell supports python 2.7 on how to start cqlsh using python 2.7
Quoting - "Depending on your distribution and its version you cannot change the default python version of the system without breaking the system."
I would recommend you to choose Debian version that uses Python2.7x natively.
(Step 1)
I'm trying to get openCV to run from python on my mac using the MacPorts install http://opencv.willowgarage.com/wiki/Mac_OS_X_OpenCV_Port, and also trying to follow The Petite Geek's guide:
sudo port -v install opencv +python26
It runs for about 10 minutes without errors.
(Step 2)
I download ctypes-opencv source and demo files. I navigate to the src directory and run:
sudo python setup.py install
I see like 50 lines almost all of the form: copying ... -> ..., which looks good to me. No errors here.
(Step 3)
I add export DYLD_FALLBACK_LIBRARY_PATH=/opt/local/lib to the end of my ~/.profile.
(Step 4)
I open a new terminal to test my install. From my home folder:
$ python
Python 2.6.2 (r262:71600, Apr 16 2009, 09:17:39)
[GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named cv
>>>
Does not work.
I read somewhere that opencv installs python bindings with the default version of python for OSX, and I am probably running a non-default version, but this is not actionable information to me.
I struggled for a while with Python on Mac. Here is how I finally (and easily!) installed it. Remove all the things Python you have on there already. They will probably be located at /Library/Frameworks/Python.Framework and /opt/local/var/macports/software/py26*
First download Python with Macports.
sudo port install python27
Then make sure your system is using this version with:
sudo port select --set python python27
Next install numpy with:
sudo port install py27-numpy
Now install opencv:
sudo port install opencv +python27
Now edit your ~/.bash_profile with:
sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit ~/.bash_profile
or
open -t ~/.bash_profile
and add the line:
export PYTHONPATH=/opt/local/var/macports/software/opencv/2.2.0_0+python27/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages:$PYTHONPATH
or where ever your version of the cv.so file is hidden....
Now restart terminal and try:
%python
>>>import cv
I'm using Netbeans for opencv and python and it works really nice. Good luck.
$ brew search opencv
homebrew/science/opencv
$ brew install homebrew/science/opencv
after installed, there is warning:
==> Caveats
If you need Python to find the installed site-packages:
mkdir -p ~/Library/Python/2.7/lib/python/site-packages
echo '/usr/local/lib/python2.7/site-packages' > ~/Library/Python/2.7/lib/python/site-packages/homebrew.pth
so, just do
mkdir -p ~/Library/Python/2.7/lib/python/site-packages
echo '/usr/local/lib/python2.7/site-packages' > ~/Library/Python/2.7/lib/python/site-packages/homebrew.pth
If you notice the first line output when running python, you'll see that you're still using the Apple-supplied Python interpreter. Try installing and using the python-select package in MacPorts and then try the instructions again starting from step 2.
Also make sure you followed all of the steps when installing MacPorts so that /usr/local/bin is on $PATH.
Another "hack" I found during my struggles using CMake (but maybe the problem is the same with ports) : it appears that the python modules location has been duplicated on my Mac OS Lion, for a reason I can't explain.
CMake wants to put the "cv" module here :
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
Whereas my default Python interpreter is looking here (thanks PyCharm for telling me) :
/Library/Python/2.7/site-packages
Moving both cv2.so and cv.py files to the second location, did the trick for me. I don't know if this is the cleanest way.
Hope it can help some googlers !
I am new to Python. I have Python2.6 running now. I am following the Tutorial on the Python site. My question is when I try to follow the instructions here:
http://py-psycopg.darwinports.com/
I get something like...
sudo port install py-psycopg
... bunch of errors here...
Error: The following dependencies failed to build: py-mx python24
I am running MacOS X 10.4.
How do i make this work?
Any reply would be greatly appreciated.
UPDATE:
After running the code below I get the errors below:
$ sudo port install py26-psycopg2
Warning: Skipping upgrade since openssl 0.9.8k_0 >= openssl 0.9.8k_0, even though installed variants "" do not match "+darwin". Use 'upgrade --enforce-variants' to switch to the requested variants.
Warning: Skipping upgrade since readline 6.0.000_1 >= readline 6.0.000_1, even though installed variants "" do not match "+darwin". Use 'upgrade --enforce-variants' to switch to the requested variants.
---> Computing dependencies for py26-psycopg2
---> Building python26
Error: Target org.macports.build returned: shell command " cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_python26/work/Python-2.6.2" && /usr/bin/make all MAKE="/usr/bin/make CC=/usr/bin/gcc-4.0" " returned error 2
Command output: /usr/bin/install -c -d -m 755 Python.framework/Versions/2.6
if test ""; then \
/usr/bin/gcc-4.0 -o Python.framework/Versions/2.6/Python -dynamiclib \
-isysroot "" \
-all_load libpython2.6.a -Wl,-single_module \
-install_name /opt/local/Library/Frameworks/Python.framework/Versions/2.6/Python \
-compatibility_version 2.6 \
-current_version 2.6; \
else \
/usr/bin/libtool -o Python.framework/Versions/2.6/Python -dynamic libpython2.6.a \
-lSystem -lSystemStubs -install_name /opt/local/Library/Frameworks/Python.framework/Versions/2.6/Python -compatibility_version 2.6 -current_version 2.6 ;\
fi
ld64 failed: in libpython2.6.a(__.SYMDEF), not a valid ppc64 mach-o file
/usr/bin/libtool: internal link edit command failed
make: *** [Python.framework/Versions/2.6/Python] Error 1
Error: The following dependencies failed to build: python26
Error: Status 1 encountered during processing.
FYI, the python i installed was the dmg file from the pythong site.
Thanks,
Wenbert
If you're using Python 2.6, you actually want to build py26-psycopg2:
$ sudo port install py26-psycopg2
In MacPorts, py-* packages build using Python 2.4, py25-* using Python 2.5, and py26-* use Python 2.6.
Maybe you need to look at the version for Python 2.6?
I had problems installing psycopg2 on my 10.4 Mac too. I installed both Python and Postgres from dmg files, and sudo easy_install psycopg2 was giving an error I can't remember now. What worked for me was an easy solution:
PATH=$PATH:/Library/PostgreSQL/8.3/bin/ sudo easy_install psycopg2
which I've found at http://blog.jonypawks.net/2008/06/20/installing-psycopg2-on-os-x/
I installed psycopg2 on my Mac with setuptools and easy_install. First get the Python 2.6 egg from the setuptools downloads page, then install it with the instructions on that page. Then you can run the following to install it:
sudo easy_install psycopg2
You may have different luck, but that's what did it for me.
I tried everything and nothing works. At least this post:
http://benkreeger.com/post/312303245/conquering-symbol-not-found-pqbackendpid
led me to homebrew which made it perfectly.