# [gelöst] Wie und wo, Python byte-compiling einschalten?

## Jule

Hallo,

wie schaltet man für Python das byte-compiling ein?

Ich muss irgendwo die Variable PYTHONDONTWRITEBYTECODE=0 setzen. 

Wie und wo ich das machen muss, dass es immer eingeschaltet ist, ist mir aber ein Rätsel.

Vielleicht noch was zur Problematik. Ich will pycurl installieren. Bekomme folgende Fehlermeldung:

```
 # emerge dev-python/pycurl

 * IMPORTANT: 4 news items need reading for repository 'gentoo'.

 * Use eselect news to read news items.

Calculating dependencies... done!

>>> Verifying ebuild manifests

>>> Emerging (1 of 1) dev-python/pycurl-7.19.0

openpty failed: 'out of pty devices'

 * pycurl-7.19.0.tar.gz RMD160 SHA1 SHA256 size ;-) ...                  [ ok ]

>>> Unpacking source...

>>> Unpacking pycurl-7.19.0.tar.gz to /var/tmp/portage/dev-python/pycurl-7.19.0/                                                                                work

>>> Source unpacked in /var/tmp/portage/dev-python/pycurl-7.19.0/work

>>> Preparing source in /var/tmp/portage/dev-python/pycurl-7.19.0/work/pycurl-7.                                                                                19.0 ...

 * Applying pycurl-7.19.0-linking.patch ...                              [ ok ]

>>> Source prepared.

>>> Configuring source in /var/tmp/portage/dev-python/pycurl-7.19.0/work/pycurl-                                                                                7.19.0 ...

>>> Source configured.

>>> Compiling source in /var/tmp/portage/dev-python/pycurl-7.19.0/work/pycurl-7.                                                                                19.0 ...

 * Building of dev-python/pycurl-7.19.0 with CPython 2.7...

python2.7 setup.py build -b build-2.7

Using curl-config (libcurl 7.24.0)

running build

running build_py

creating build-2.7

creating build-2.7/lib.linux-x86_64-2.7

creating build-2.7/lib.linux-x86_64-2.7/curl

copying python/curl/__init__.py -> build-2.7/lib.linux-x86_64-2.7/curl

warning: build_py: byte-compiling is disabled, skipping.

running build_ext

building 'pycurl' extension

creating build-2.7/temp.linux-x86_64-2.7

creating build-2.7/temp.linux-x86_64-2.7/src

i486-pc-linux-gnu-gcc -pthread -Os -mtune=i686 -pipe -fPIC -DHAVE_CURL_OPENSSL=1                                                                                 -DHAVE_CURL_OPENSSL=1 -DHAVE_CURL_SSL=1 -I/usr/include/python2.7 -c src/pycurl.                                                                                c -o build-2.7/temp.linux-x86_64-2.7/src/pycurl.o

src/pycurl.c:79:31: error: openssl/crypto.h: No such file or directory

src/pycurl.c: In function 'pycurl_ssl_lock':

src/pycurl.c:393: error: 'CRYPTO_LOCK' undeclared (first use in this function)

src/pycurl.c:393: error: (Each undeclared identifier is reported only once

src/pycurl.c:393: error: for each function it appears in.)

error: command 'i486-pc-linux-gnu-gcc' failed with exit status 1

 * ERROR: dev-python/pycurl-7.19.0 failed (compile phase):

 *   Building failed with CPython 2.7 in distutils_building() function

 *

 * Call stack:

 *     ebuild.sh, line   56:  Called src_compile

 *   environment, line 5075:  Called distutils_src_compile

 *   environment, line 1227:  Called python_execute_function 'distutils_building                                                                                '

 *   environment, line 3414:  Called die

 * The specific snippet of code:

 *                       die "${failure_message}";

 *

 * If you need support, post the output of 'emerge --info =dev-python/pycurl-7.1                                                                                9.0',

 * the complete build log and the output of 'emerge -pqv =dev-python/pycurl-7.19                                                                                .0'.

 * The complete build log is located at '/var/tmp/portage/dev-python/pycurl-7.19                                                                                .0/temp/build.log'.

 * The ebuild environment file is located at '/var/tmp/portage/dev-python/pycurl                                                                                -7.19.0/temp/environment'.

 * S: '/var/tmp/portage/dev-python/pycurl-7.19.0/work/pycurl-7.19.0'

>>> Failed to emerge dev-python/pycurl-7.19.0, Log file:

>>>  '/var/tmp/portage/dev-python/pycurl-7.19.0/temp/build.log'

 * Messages for package dev-python/pycurl-7.19.0:

 * ERROR: dev-python/pycurl-7.19.0 failed (compile phase):

 *   Building failed with CPython 2.7 in distutils_building() function

 *

 * Call stack:

 *     ebuild.sh, line   56:  Called src_compile

 *   environment, line 5075:  Called distutils_src_compile

 *   environment, line 1227:  Called python_execute_function 'distutils_building                                                                                '

 *   environment, line 3414:  Called die

 * The specific snippet of code:

 *                       die "${failure_message}";

 *

 * If you need support, post the output of 'emerge --info =dev-python/pycurl-7.1                                                                                9.0',

 * the complete build log and the output of 'emerge -pqv =dev-python/pycurl-7.19                                                                                .0'.

 * The complete build log is located at '/var/tmp/portage/dev-python/pycurl-7.19                                                                                .0/temp/build.log'.

 * The ebuild environment file is located at '/var/tmp/portage/dev-python/pycurl                                                                                -7.19.0/temp/environment'.

 * S: '/var/tmp/portage/dev-python/pycurl-7.19.0/work/pycurl-7.19.0'

 * IMPORTANT: 4 news items need reading for repository 'gentoo'.

 * Use eselect news to read news items.

```

Ein export=PYTHONDONTWRITEBYTECODE=0 hat nix gebracht, die Installation läuft immer noch mit der Fehlermeldung ab.Last edited by Jule on Fri Mar 02, 2012 8:38 am; edited 1 time in total

----------

## theotherjoe

Würde vermuten, dass openssl nicht mit USE="python" compiliert/installiert wurde.

Zeig doch mal was folgendes command ausgibt:

```
# emerge -pv openssl

```

----------

## franzf

Das Problem hat doch nix mit bytecode-compiling zu tun. Python-Programme werden interpretiert (.py-Dateien sind plain-text). Das kann ganz schön dauern. Dafür kann man das Python-Programm in ein Zwischenformat - den Bytecode - kompilieren. Dieser startet schnell als das ursprüngliche Programm aus dem .py. Python-Bytecode-files enden üblicherweise auf ".pyc".

Was du hier hast ist ein klassischer gcc-compiler-Fehler beim Kompilieren eines C-Quelltextes.

Kannst du mal zeigen, mit welchen USE-Flags du curl gebaut hast?

----------

## Jule

Ok, wenn ich 

```
USE="python" emerge openssl 
```

 geht es.

Hab es also tatsächlich verpeilt, Openssl mit Python Support zu bauen.

Die Fehlermeldung, hat mich aber, auf die Spur mit dem byte-compiling gebracht, war wohl naiv von mir zu glauben dass wäre es gewesen.

 Vielen Dank an Euch.

----------

## franzf

Wenn das geholfen hat, hattest du einfach eine fehlerhafte openssl-Installation. openssl hat KEIN python-USE-Flag. Es hätte auch mit USE="-python" emerge openssl funktioniert  :Wink:  Oder einfach nur emerge openssl.

BTW. hast du jetzt ein unnötiges Paket in deiner world-Datei (*)  :Wink:  openssl ist nämlich eine Abhängigkeit von vielen anderen Paketen. Bei solchen Paketen in Zukunft die Option "--oneshot" oder kurz "-1" bei emerge mit angeben, dann wird das worldfile nicht angerührt. worldfile manuell editieren und openssl wieder rausschmeißen  :Smile: 

(*) üblicherweise ist das /var/lib/portage/world

----------

