yujiang / python-for-android

Automatically exported from code.google.com/p/python-for-android
Apache License 2.0
0 stars 1 forks source link

sys.path is hardcoded to python2.1 paths. this interferes with importing some modules like struct or ctypes from command line #2

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

$ export PYTHONHOME=/data/data/com.googlecode.pythonforandroid/files/python
$ export PYTHONPATH=/sdcard/com.googlecode.pythonforandroid/extras/python
$ export PATH=$PYTHONHOME/bin:$PATH
$ export 
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/sdcard/lib:/data/data/com.googlecode.pythonfor
android/files/python/lib:/data/data/com.googlecode.pythonforandroid/files/python
/lib/python2.6/lib-dynload

$ python
Python 2.6.2 (r262:71600, Feb 14 2011, 10:32:30) 
[GCC 4.4.3] on linux-armv7l
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/sdcard/com.googlecode.pythonforandroid/extras/python', 
'/data/data/com.googlecode.pythonforandroid/files/python/lib/python21.zip', 
'/usr/local/lib/python2.1', '/usr/local/lib/python2.1/lib-dynload', 
'/data/data/com.googlecode.pythonforandroid/files/python/lib/python2.1/lib-dynlo
ad']

>>> import struct
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/manuel/AptanaStudio3Workspace/python-for-android/python-build/output/usr/lib/python2.6/struct.py", line 1, in <module>
ImportError: No module named _struct

# After manually fixing sys.path, I can import the struct module without 
problem:

>>> sys.path=['', '/sdcard/sl4a/scripts', 
'/sdcard/com.googlecode.pythonforandroid/extras/python', 
'/data/data/com.googlecode.pythonforandroid/files/python/lib', 
'/data/data/com.googlecode.pythonforandroid/files/python/lib/python2.6/lib-dynlo
ad']
>>> import struct
>>> 

What is the expected output? What do you see instead?

I expected to see sys.path to reflect what I specified in the "export" 
statements.  Instead, I see some some references to python2.1 in sys.path.  I 
tracked down that the python2.1 references are hard coded in libpython2.6.so:

$ strings 
/data/data/com.googlecode.pythonforandroid/files/python/lib/libpython2.6.so | 
grep python2.1
/usr/local/lib/python2.1:/usr/local/lib/python2.1/lib-dynload
lib/python2.1

What version of the product are you using? On what operating system?

I'm running the latest Py4A on a rooted HTC EVO with Android 2.2.

Please provide any additional information below.

Thanks very much for working on Py4A!!

Original issue reported on code.google.com by paul.dan...@gmail.com on 18 Feb 2011 at 4:57

GoogleCodeExporter commented 8 years ago
I noticed this as well when working on the build process, but wasn't able to 
identify who does this. Would you mind in building Py4A your self and see if 
you can find it? I have no clue on what to do to fix this.

Original comment by naranjo....@gmail.com on 18 Feb 2011 at 5:39

GoogleCodeExporter commented 8 years ago
Fixed in r16

Original comment by rjmatthews62 on 20 Mar 2011 at 7:05

GoogleCodeExporter commented 8 years ago

Original comment by rjmatthews62 on 20 Mar 2011 at 7:05