waf build system can not find python libraries - python

i'm trying to build pycairo-1.0 for python3 and getting bad output
root#blackenedsun:/home/blackenedsun/Downloads/pycairo-1.10.0# ./waf configure --prefix=/usr
./options()
Setting top to : /home/blackenedsun/Downloads/pycairo-1.10.0
Setting out to : /home/blackenedsun/Downloads/pycairo-1.10.0/build_directory
./configure()
Checking for 'gcc' (c compiler) : ok
Checking for program python : /usr/local/bin/python
Checking for python version : (3, 3, 2, 'final', 0)
Checking for library python3.3 in LIBDIR : not found
Checking for library python3.3 in python_LIBPL : not found
Checking for library python3.3 in $prefix/libs : not found
Checking for library python3.3m in LIBDIR : yes
Checking for program python3.3-config : /usr/bin/python3.3-config
command ['/usr/local/bin/python', '/usr/bin/python3.3-config', '--includes'] returned 1
root#blackenedsun:/home/blackenedsun/Downloads/pycairo-1.10.0#
what can i do to find python3.3 libraries properly?

I get the same problem with python 3.4.
It is due to waf trying to execute python3.4-config with python while python3.4-config is a shell script.
In fact launching python3.4-config alone works perfectly.
[dusserm#l92-ci-e pycairo-1.10.0]$ python3 /Produits/publics/x86_64.Linux.RH6/python/3.4.1/bin/python3.4-config --includes
File "/Produits/publics/x86_64.Linux.RH6/python/3.4.1/bin/python3.4-config", line 7
echo "Usage: $0 --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--help|--abiflags|--configdir"
^
SyntaxError: invalid syntax
[dusserm#l92-ci-e pycairo-1.10.0]$ /Produits/publics/x86_64.Linux.RH6/python/3.4.1/bin/python3.4-config --includes
-I/nfs/nfs/Produits/publics/x86_64.Linux.RH6/python/3.4.1/include/python3.4m -I/nfs/nfs/Produits/publics/x86_64.Linux.RH6/python/3.4.1/include/python3.4m
The problem comes from waf not using python3.X-config correctly.
The workaround I found is to modify directly the hidden directory in which the waf scripts are unzipped (in my case .waf3-1.6.4-e3c1e08604b18a10567cfcd2d02eb6e6).
Go to this directory an change the file waflib/Tools/python.py to call python3.X-config directly without python.
--- waflib/Tools/python.py.old 2014-08-01 14:36:23.750613874 +0000
+++ waflib/Tools/python.py 2014-08-01 14:36:38.359627761 +0000
## -169,7 +169,7 ##
conf.find_program('python-config-%s'%num,var='PYTHON_CONFIG',mandatory=False)
includes=[]
if conf.env.PYTHON_CONFIG:
- for incstr in conf.cmd_and_log(conf.env.PYTHON+[conf.env.PYTHON_CONFIG,'--includes']).strip().split():
+ for incstr in conf.cmd_and_log([conf.env.PYTHON_CONFIG,'--includes']).strip().split():
if(incstr.startswith('-I')or incstr.startswith('/I')):
incstr=incstr[2:]
if incstr not in includes:

I got the same problem. And I fixed by adding system variable like this:
['/usr/local/bin/python3.4', '/usr/local/bin/python3.4-config',
'--includes'] returned 1
export PYTHON_CONFIG="/usr/local/lib/python3.4/config-3.4m/python-config.py"

Related

command not found when using makefile to run batch file on Windows 10

When I try to run a makefile (type "make test" in terminal) which runs a batch file I get the equivalent error:
cd directory_path && test.bat
/bin/sh: test.bat: command not found
make: *** [makefile:58: test] Error 127
The makefile is:
.PHONY: test
test:
cd directory_path && test.bat
python path/test.py
(I changed names of the batch file, the directory path, etc. to try and make things more generic)
I can manually type "cd directory_path" and then "test.bat" and those both work. This makefile works on other systems. It only doesn't work on mine. I think it is an issue with how I installed Cygwin and how I run "make.exe".
I can use make to compile C code, but I also get an error trying to use make to run python scripts. The makefile from before also has a command for python path/test.py. This also isn't working on my system. If I delete the batch file line, but keep the python command it throws the error:
python path/test.py
make: python: No such file or directory
make: *** [makefile:59: test] Error 127.
I don't understand why it throws the error of no such file or directory since the path leads to the file, and if i put the python script in the same working directory as the makefile then it still can't find it.
Any ideas/solutions on these problems? Thank you!
EDIT:
Doug Henderson:
I started a cmd prompt at the place with the make file and entered all of these commands in
uname -a
CYGWIN_NT-10.0 james-mobl2 3.1.6(0.340/5/3) 2020-07-09 08:20 x86_64 Cygwin
which make
/usr/bin/make
make -v
GNU Make 4.3
Built for x86_64-pc-cygwin
Copyright (C) 1988-2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
which python
which: no python in
(/cygdrive/c/Program Files/AdoptOpenJDK/jdk-8.0.252.09-hotspot/bin:
/cygdrive/c/windows/system32:
/cygdrive/c/windows:
/cygdrive/c/windows/System32/Wbem:
/cygdrive/c/windows/System32/WindowsPowerShell/v1.0:
/cygdrive/c/windows/System32/OpenSSH:
/cygdrive/c/Program Files/Git/cmd:
/cygdrive/c/Users/james/AppData/Local/Microsoft/WindowsApps/python:
/cygdrive/c/Program Files/PuTTY:
/usr/bin:
/cygdrive/c/Program Files/AdoptOpenJDK/jdk-8.0.252.09 hotspot/bin:
/cygdrive/c/Users/james/AppData/Local/Microsoft/WindowsApps)
(I cleaned up the output a little to make it more legible). This and which test.bat are the only commands that failed.
python -V
Python 3.8.5
The change directory changed correctly
which test.bat
which: no test.bat in
(/cygdrive/c/Program Files/AdoptOpenJDK/jdk-8.0.252.09-hotspot/bin:
/cygdrive/c/windows/system32:
/cygdrive/c/windows:
/cygdrive/c/windows/System32/Wbem:
/cygdrive/c/windows/System32/WindowsPowerShell/v1.0:
/cygdrive/c/windows/System32/OpenSSH:
/cygdrive/c/Program Files/Git/cmd:
/cygdrive/c/Users/james/AppData/Local/Microsoft/WindowsApps/python:
/cygdrive/c/Program Files/PuTTY:
/usr/bin:
/cygdrive/c/Program Files/AdoptOpenJDK/jdk-8.0.252.09 hotspot/bin:
/cygdrive/c/Users/james/AppData/Local/Microsoft/WindowsApps)
I added cmd /c test.bat to the makefile and it worked, but I've also had the batch file run on different systems without that addition. I also have a lot batch files in the actual makefile so this solution works but isn't ideal. It also didn't fix the python script not running.
I didn't initially have cmd.exe in my path, but I added it before entering those commands.
I'm not sure what you mean by starting my PATH in bash with /usr/bin;/bin;THE_REST
MadScientist:
I was manually entering it into a Windows Terminal. Is it possible to have Cygwin invoke a Windows command.com shell?
What I did was go to directory that contained the makefile. Open a windows terminal by typing 'cmd' in the address bar. I would then type 'make test'. That obviously led to the issues. I then went through and manually entered the commands I thought the makefile was supposed to invoke. So I entered 'cd directory_path && test.bat'. This ran.
Matzeri:
I don't really know. I'm completely new to POSIX, etc. I'm guessing I'm using Windows style, and judging from other responses, I'm trying to use Cygwin to do a non-POSIX style.
Thank you, everyone for responses!
Make sure cygwin is installed with basic packages --> Some basic packages not installed with cygwin try below link to install some basic package, uninstall the cygwin and install it again with following basic package :
https://wiki.usask.ca/display/MESH/Running+Python+from+the+Cygwin+Terminal#RunningPythonfromtheCygwinTerminal-Cygwin
make sure cygwin's bin folder is added to your environment variable (e.g., C:\cygwin64\bin)
If cmd /c test.bat works then . is probably not in your PATH. Always do ./test.bat when you want to run something in the current directory. Never count on the PATH unless you have set it yourself. Also make sure the file is executable. chmod +x test.bat

problem in checking whether python 3 is installed

I want to check whether python 3 is installed on my Ubuntu. I'm using this script:
#!/usr/bin/env sh
#install firefox if does not exist
if ! command -v python3 >/dev/null 2>&1
then
echo "not installed"
else
echo "installed"
fi
When I run this script, the output is installed, but when I check my python using python --version, I get this output:
Python 2.7.17
Which, as far as I know, means that the latest version of python on my Ubuntu is 2.7 not 3.x. What's wrong?
The output of command -v python3; echo $?:
/usr/bin/python3
0
The output of ls -l /usr/bin/python3:
lrwxrwxrwx 1 root root 9 Nov 14 09:13 /usr/bin/python3 -> python3.7
The output of ls -l /usr/bin/python3.7:
-rwxr-xr-x 2 root root 5102632 Oct 27 11:43 /usr/bin/python3.7
The output of which python:
/usr/bin/python
The output of ls -l /usr/bin/python:
lrwxrwxrwx 1 root root 7 Jan 19 08:04 /usr/bin/python -> python2
The output of ls -l /usr/bin/python2:
lrwxrwxrwx 1 root root 9 Jan 19 08:04 /usr/bin/python2 -> python2.7
Also I have another Ubuntu on a separate VM, the output of python --version, returns command 'python' not found, but when I execute the above commands for this VM as well, it returns similar responses (indicating that python is installed).
https://www.python.org/dev/peps/pep-0394/
Note: You can have an environment where you have both Python 2 and Python 3 installed, and python can point to either. (Most likely python2 for backward compatibility purpose.) Python 3 applications should always use the python3 command and not python.
Try the whereis command. It will tell you where python3 is.
whereis python
Or better yet
whereis python3
The output should be a path, or a list of paths. You might see something like:
python3: /usr/bin/python3.6m /usr/bin/python3.6 /usr/bin/python3.6m-config
/usr/bin/python3 /usr/bin/python3.6-config /usr/lib/python3.6 /usr/lib/python3
/usr/lib/python3.7 /usr/lib/python3.8 /etc/python3.6 /etc/python3 /usr/local
Then make sure your PATH variable has at least one of the directories above within it. The PATH environment variable is essentially a list of directories that contain executables (programs). When you type something on your command line your terminal program will search the directories listed in PATH for the executable you specified.
echo $PATH
/home/USER/.pyenv/shims:/home/USER/.pyenv/bin:/home/USER/esp/xtensa-esp32-
elf/bin:/home/USER/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:
/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
You might have a directory in your PATH that is messing things up, or you might need to add a new directory.
Because so many programs have been written using Python 2, many operating systems keep Python 2 in their repository, and this isn't going to change any time soon.
So when you installed Python, it added Python 2 to /usr/bin/ (maybe /usr/bin/python2, maybe /usr/bin/python2.7, etc.), and pointed /usr/bin/python to the same location. When you installed Python 3 it also installed Python 3, to /usr/bin/python3.
When you test whether python3 is installed, you find that it is. According to PEP 394, /usr/bin/python should refer to Python 2. Ubuntu documentation explains what that means and what it doesn't:
What this does not mean:
/usr/bin/python will point to Python 3. No, this is not going to happen (unless PEP 394 advocates otherwise, which is doubtful for the foreseeable future). /usr/bin/python and /usr/bin/python2 will point to Python 2.7 and /usr/bin/python3 will point to the latest supported Python 3 version.
Python 2 will be removed from the archive. No, this is not going to happen. We expect Python 2.7 to remain supported and available in Ubuntu for quite a long time, given that PEP 373 promises upstream bug fix maintenance support until 2020. It would be nice if we could demote Python 2 to universe, but that's currently problematic for technical reasons relating to multi-Python version support in Debian/Ubuntu.
Basically, while all development should be geared toward Python 3, the python command (/usr/bin/python) should point to Python 2 in order to keep current programs from breaking.
If you'd like to access Python 3, it's recommended that you call python3. (You could also rebind /usr/bin/python to point to python3, but this is highly unrecommended. A more useful solution to most users would be to create an alias to python3.)
Short version: Your script works. Python 3 is installed. If you want the terminal to open Python 3 when you type python, add an alias alias python=python3.

Could not find hostpython, will not compile to .pyo (Buildozer python-to-android)

I'm using Buildozer to convert a python file to android APK (using Kivy) and it gets quite far through the process but then errors.
Any ideas what is causing this error at the end?
toolchain.py: error: unrecognized arguments: --sdk 19 Could
not find hostpython, will not compile to .pyo (this is normal with
python3)
Command failed: /usr/bin/python -m pythonforandroid.toolchain apk --debug --bootstrap=sdl2 --dist_name KivyTest --name KivyApp --version 0.1 --package doublejgames.com.kivytest --android_api 19 --sdk 19 --minsdk 9 --private /home/kivy/Desktop/.buildozer/android/app --orientation landscape --copy-libs --arch armeabi-v7a --color=always --storage-dir=/home/kivy/Desktop/.buildozer/android/platform/build
This seems to be the main error:
toolchain.py: error: unrecognized arguments: --sdk 19 Could
not find hostpython, will not compile to .pyo (this is normal with
python3)
In my buildozer.spec file, I'm using the requirements:
requirements = kivy, python3crystax==3.6
I also tried just
requirements = kivy, python3crystax
Any help would be appreciated! Thanks.
specify the requirments with the version in the .spec file which you run in your local machine which building the application. try to run python 3.7 or 3.6 python does not support version than 3.9
The error is the 'error: unrecognized arguments: --sdk 19' part, the rest is not important. The problem arises from a regression in python-for-android, as this argument was removed but is still passed by buildozer. I've re-added the argument (with a deprecation warning) and created a PR to stop buildozer calling it anyway. This means that if you clean everything and try again, the error should no longer occur.

Emacs Inferior Python shell shows the send message with each python-shell-send-region command

I am using the Python inferior shell on OS X (El Capitan) and every time I send a piece of code to the Python process (using C-c C-r which is bound to python-shell-send-region) I get a message like this in the Python shell:
>>> import codecs, os;
__pyfile = codecs.open('''/var/folders/6j/g9hcs1s17g1dgxr3p_m04rq80000gn/T/py5013kfY''', encoding='''utf-8''');
__code = __pyfile.read().encode('''utf-8''');
__pyfile.close();
os.remove('''/var/folders/6j/g9hcs1s17g1dgxr3p_m04rq80000gn/T/py5013kfY''');
exec(compile(__code, '''/Users/user/Desktop/sample.py''', 'exec'));
I would like to not have this message shown with each invocation of the command. The same version of Emacs on Linux (together with python.el file) does not have this problem. The template of the message is defined in python-shell-send-file function (in python.el file), which in itself is puzzling as I cannot see how this function is called when I invoke python-shell-send-region. For the first run I invoke the Python interpreter (version 2.7.10) with the following command
/usr/bin/python -i
but it also behaves the same with other python interpreters (installed via brew). I am using Emacs 24.5.1 (again installed via brew). The only python-mode specific configuration I use in .emacs are related to the tab width:
(add-hook 'python-mode-hook
(lambda ()
(setq indent-tabs-mode t)
(setq tab-width 2)
(setq python-indent 2)))
Any help or suggestion is appreciated.
Edit and a possible solution:
(I found this https://github.com/jorgenschaefer/elpy/issues/1307):
$ easy_install-3.6 gnureadline
$ cd /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/lib-dynload
$ mv readline.cpython-36m-darwin.so readline.cpython-36m-darwin.so.bak
If you get an error while installing gnureadline, fatal error: 'stdio.h' file not found, try xcode-select --install.
$ source ./your/venv/activate
$ pip install pyreadline
Should work automatically with Python. I experienced a similar issue on Windows 10 earlier this year, installing pyreadline as a dev dependency resolved it.

cannot compile cpp files under the python pyc script file

I am trying to compile & execute my hw cpp file under the python script file which we are given by lecturer. the how-to-manual.pdf he sent us it says use:
c:\>python ./submit.pyc problemID -u username -p password -b //submit.pyc is already given to us
and here is the manifest.txt we are given:
[main]
problem = gc
build =
g++ main.cpp -o solver
run =
./solver %f
my cpp file works normally like this:
./solver input_file
However, I am trying (I have to) to do this under the windows OS. I have Python 2.7.x installed and python.exe is in the Command PATH. I can't run it under the linux ssh sytem because there is 2.4.x python installed and I can't touch it (school's system).
Anyway, when I execute the line above, it returns me:
Command execution failed:
g++ solver.cpp -o solver
I think I told everything I can. So, any idea that what I have to do else? except asking to lecturer:)
For the above to work it needs to be able to find g++ so you need to add the directory that it resides in to the PATH environment variable. This can be done from within your python script or on the command line with:
path=Where\g++\lives;%path%
This will only apply within the current DOS session.
Or you can add it permanenty through system settings->advanced settings->environmental variables
You could also look at using a python virtual environments on the schools linux system.

Categories

Resources