Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to check which compiler was used to build Python

Is there a way to tell which compiler was used to build a Python install on a specific linux machine?

I tried using ldd on the Python dynamic libraries [1], but I didn't manage to understand if it was compiled with gcc or Intel compiler.

[1]

$ ldd libpython2.7.so.1.0
linux-vdso.so.1 =>  (0x00007fff4a5ff000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00002ab8de8ae000)
libdl.so.2 => /lib64/libdl.so.2 (0x00002ab8deac9000)
libutil.so.1 => /lib64/libutil.so.1 (0x00002ab8deccd000)
libm.so.6 => /lib64/libm.so.6 (0x00002ab8deed1000)
libc.so.6 => /lib64/libc.so.6 (0x00002ab8df154000)
/lib64/ld-linux-x86-64.so.2 (0x0000003b9a400000)
like image 290
Andrea Zonca Avatar asked Mar 11 '13 23:03

Andrea Zonca


People also ask

How do I know what compiler I have?

Type “gcc –version” in command prompt to check whether C compiler is installed in your machine.

Can MinGW compile Python?

MinGW is an alternative C/C++ compiler that works with all Python versions up to 3.4.

Does Python need any compiler?

For the most part, Python is an interpreted language and not a compiled one, although compilation is a step. Python code, written in . py file is first compiled to what is called bytecode (discussed in detail further) which is stored with a . pyc or .


1 Answers

Easiest way in the REPL, you have it in sys.version:

>>> import sys
>>> print(sys.version)
3.7.0 (default, Jul 24 2018, 19:03:02) 
[GCC 8.1.0]

It should also usually tell you when you start the interactive interpreter:

$ python3
Python 3.7.0 (default, Jul 24 2018, 19:03:02) 
[GCC 8.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

Easiest way at the shell: pass the command line option -V twice to print info about the build. It seems this is a new feature and is missing in Python 2.

$ python3 -VV
Python 3.7.0 (default, Jul 24 2018, 19:03:02) 
[GCC 8.1.0]
like image 159
wim Avatar answered Oct 14 '22 02:10

wim