Found Python3.9, but I want to use python3.10 - python

Due to some breakage in another project that didn't run in python3.10 I had to install python 3.9 on my ubuntu 22.04 machine. Because python3.9 is not available in the package repositories, I cloned the github repository and ran configure, make and make install, which installed python3.9 into /usr/local/bin.
Now I am trying to compile pivy against python3.10, which is my default python version. But I think CMake picks up python3.9 now by default. I tried reinstalling python with sudo apt install python3 --reinstall, but that didn't help. I also tried to replace all occurrences of python3.9 with python3.10 in the files generated by cmake, but that also gave an output of -- Found Python: /usr/local/bin/python3.9 (found version "3.9.13") found components: Interpreter Development Development.Module Development.Embed on the first line of make.
I have found a similar question, but it doesn't exactly match what I want. Firstly, I don't know what the installation directory for the apt python version is. the python binary is in /usr/bin/, but so could be the 3.9 version (it's in /usr/local/bin/ right now). Secondly, I would like to have that as the default.
I have tried removing the softlink to python3.9-config in /usr/local/bin/python3-config
and running python3-config now runs the one in /usr/bin/python3-config, which points to the 3.10 version. However running cmake now says it can't find python at all. Even after clearing the cmake cache and reseting the repository.
CMake Error at /usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find Python (missing: Python_EXECUTABLE Python_INCLUDE_DIRS
Python_LIBRARIES Interpreter Development Development.Module
Development.Embed)
Call Stack (most recent call first):
/usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
/usr/share/cmake-3.22/Modules/FindPython.cmake:561 (find_package_handle_standard_args)
CMakeLists.txt:17 (find_package)
I have tried creating a new softlink to the correct python3-config in /usr/local/bin, but that gave the same cmake error.
apt-file search FindPython revealed that that file is in the cmake-data package, which I reinstalled. That also didn't work.
I don't know what to do now. How can I make cmake find the correct python version by default? There are no entries for python or python3 in update-alternatives. I noticed there are a lot more python executables in /usr/local/bin/, for example python-argcomplete-tcsh, is that a problem if I want to use 3.10 by default?
I was able to get around the issue for now using
cmake .. -DCMAKE_BUILD_TYPE=Release -DPython_EXECUTABLE=/usr/bin/python3.10 -DPython_INCLUDE_DIRS=/usr/include/python3.10/
But that's only a stopgap measure. I would like a proper solution that makes FindPython work properly again.

Related

MKL Issues installing PyFlashlight

I am attempting to install from a Python setup. I had this working after a month of hell-ish attempts on 18.04, and now need it on 20.04.
The setup.py while I am using is on this repository ( https://github.com/flashlight/flashlight/tree/main/bindings/python ).
I am using Ubuntu 20.04, fresh install sans a few dependencies I know the system needs.
I have Python3.10 installed locally.
During the install at steps
cd bindings/python
python3.10 setup.py install
I hit the error
CMake Error at cmake/FindMKL.cmake:400. MKL library not found. Please specify the library location by appending the root directory of the MKL installation to the environment variable CMAKE_PREFIX_PATH
Which is weird for a variety of reasons.
I did a sudo apt-get install mkl-devel which took, but also
The setup script claims it defaults to MKL off.
Right prior to this error, I do get a warning.
Cmake Warning at cmake/FindMKL.cmake:387. MKL libraries files are found, but MKL header files are not. You can get them by 'pip install mkl-devel' (I did this btw) if using pip. If build fails with header files available on the system, please make sure that CMake will search the directory containing them by setting CMAKE_INCLUDE_PATH
That last part I did not do, primarily because I'm not sure how to tell where pip install mkl-devel would have put those header files.
That said, when I do a find / "*mkl*" I notice files in two primary locations
.h files : /home/myusername/.local/include
.so files: /home/myusername/.local/lib
So I set the following environment variables in my terminal
LIBRARY_PATH=/home/myusername/.local/lib
LD_LIBRARY_PATH=/home/myusername/.local/lib
KENLM_ROOT=/home/myusername/Flashlight/kenlm
USE_MKL=0
CMAKE_INCLUDE_PATH=/home/myusername/.local/include/
CMAKE_PREFIX_PATH=/home/myusername/.local/lib
However when I try to install again, the process still fails with both of the MKL issues above (Warning and Error)
I'm baffled at what I am supposed to be pointing where to get this to succeed at this point.

How to fix : pyconfig.h not found with Anaconda

I am setting up boost-python for the python bindings of a library. Previously, boost was installed but linked against python2.7. After some tribulations, everything from the previous boost install is gone and I am trying to install a fresh boost.
I am using Linux Mint for the record, and Anaconda with python 3.6.8.
It works correctly in the CLI : python --version gives 3.6.8
I then begin to follow the instructions for building boost : https://www.boost.org/users/history/version_1_69_0.html
What I got from other threads is to do this :
sudo apt-get install python3-dev
I am not sure I am supposed to since I have anaconda3 but anyway, I did it.
./bootstrap.sh
here the file project-config.jam is created and the line about python says :
using python : 3.6 : /home/myUser/anaconda3 ;
I then proceed to build with b2 :
sudo ./b2 --with-python -j8 install
the installation fails with literally a wall of text full of these :
./boost/python/detail/wrap_python.hpp:50:11: fatal error:
pyconfig.h: No such file or directory
# include <pyconfig.h>
^~~~~~~~~~~~
compilation terminated.
When I search inside ~/anaconda3/include/python3.6m the file pyconfig.h sits there as expected
Is there additional information I should give to b2 or bootstrap ?
I face the same problem for installing boost 1.70 and Anaconda3 with python Anaconda with python 3.7.1. I found an answer based on this question.
Ubuntu - Linking boost.python - Fatal error: pyconfig cannot be found
By the way to solve this problem first you should find the "pyconfig.h" file in the installation directory of Anaconda. For me it's in "~/anaconda3/include/python3.7m". Then export this address or just add this address to the .bashrc file.
export CPLUS_INCLUDE_PATH="$CPLUS_INCLUDE_PATH:path/to/your/Anaconda3/include/python3.7m"
Put the address to Anaconda in your pc instead of path/to/your/Anaconda3. Remember to restart the terminal after this. Then again just run "./b2" in the boost folder. It should compile the rest.

How to Install openbabel for Python 3.6 on macOS Sierra 10.12.3

I am using Python for making a script to work with some chemical structures in my PhD. I want to install openbabel libraries for python. I tried my best but I could not install it on Windows. I posted a question earlier about installing it on Windows at How do I install openbabel for Python 3.6 in Windows 10? but could not find a solution. The solution installed the library but it does not work and could not connect to SWIG.
No I am trying to install it on my office computer which is a mac for past 5 hours but I could not figure what is going on.
I tried to install it from source code of Opnbabel and link it with python3 but it is making problem.
If I use the following command:
cmake ../ -DPYTHON_BINDINGS=ON -DRUN_SWIG=ON
It successfully links it to Python 2.7 which I do not want. When I try the following options, it gives the error shown below:
cmake ../ -DPYTHON_EXECUTABLE=/usr/bin/python3 -DPYTHON_BINDINGS=ON -DRUN_SWIG=ON
OR
cmake ../ -DRUN_SWIG=ON -DPYTHON_EXECUTABLE=/usr/bin/python3 -DPYTHON_INCLUDE_DIR=/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -DPYTHON_LIBRARY=/Library/Frameworks/Python.framework/Versions/3.5/lib/libpython3.5m.dylib -DPYTHON_BINDINGS=ON
It gives the following error at the end after a lot of successful output:
-- Found PythonInterp: /usr/bin/python3.6 (found version "1.4")
-- Found SWIG: /usr/local/bin/swig (found version "3.0.12")
-- Found SWIG: /usr/local/bin/swig (found suitable version "3.0.12", minimum required is "2.0")
-- Found PythonLibs: /usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/libpython3.6m.dylib (found version "3.6.0")
-- Python bindings will be compiled
CMake Error at scripts/CMakeLists.txt:120 (install):
install TARGETS given no LIBRARY DESTINATION for module target
"bindings_python".
CMake Error at scripts/CMakeLists.txt:123 (install):
install FILES given no DESTINATION!
CMake Error at scripts/CMakeLists.txt:126 (install):
install FILES given no DESTINATION!
-- Configuring incomplete, errors occurred!
See also "/usr/local/Cellar/obabel/openbabel-master/ali/CMakeFiles/CMakeOutput.log".
See also "/usr/local/Cellar/obabel/openbabel-master/ali/CMakeFiles/CMakeError.log".
I am not sure why It detects the Python as v1.4 -- Found PythonInterp: /usr/bin/python3.6 (found version "1.4") instead of finding v.3.5.
I tried all the procedure with python 3.6 as well but the same errors occur. I am also using the openbabel obtained from github which was said to be working with these commands at the following post: http://forums.openbabel.org/OpenBabel-for-Python-3-td4659432.html
But it doesn't work as well.
Please help me as I require this module for my research.
Thanks
I found the solution for that. Here is the detailed solution:
Download Open Babel from its original source (https://github.com/openbabel/openbabel)
Extract it and cd into it (openbabel-master)
Make a directory “build” and cd into it.
RUN the following command:
cmake ../ -DPYTHON_EXECUTABLE=/Library/Frameworks/Python.framework/Versions/3.5/bin/python3 -DPYTHON_BINDINGS=ON -DRUN_SWIG=ON
In the command above, the “-DPYTHON_EXECUTABLE” switch tells it the path where Python3 interpretor is found. You can check it by which python3 at a terminal.
make
make install
All Done! :)

NVM fails to install any version of Node.js in Cygwin

I've already learned that Node.js opted out of supporting Cygwin in the newer version, but NVM can't install the older version either. The error I'm getting:
$ nvm install v0.4.12
Additional options while compiling:
######################################################################## 100.0%
C:\Python27\python.exe: can't open file '/home/wvxvw/.nvm/src/node-v0.4.12/tools\
/waf-light': [Errno 2] No such file or directory
nvm: install v0.4.12 failed!
(formatted for readability)
I think this is because of Python binaries aren't aware of Cygwin-style path (and cannot find /home/ directory) I tried building from sources (same version) and am facing the same problem). I'm not sure however what to do. I wouldn't like to change Python installed in Windows for Python that can be installed through Cygwin. And if this error isn't just the tip of the iceberg, I'd maybe just change the Makefile.
The question is directed to those who might tell whether it makes sense to try to "fix" the Makefile, or should I just use Cygwin's version of Python (its problem is very buggy fork, but I think I could live with that...)
Command is not correct , use version without v. Try : nvm install 0.4.12

Homebrew failing to install postgresql; python 64-bit errors

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.

Categories