Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

PYTHONPATH lookup failure #244

Closed
nyannko opened this issue Sep 26, 2018 · 12 comments
Closed

PYTHONPATH lookup failure #244

nyannko opened this issue Sep 26, 2018 · 12 comments

Comments

@nyannko
Copy link

nyannko commented Sep 26, 2018

Hi,

I was trying to import python application to graphene OS, and I met the following problem.

Without the modification of the python.manifest.tamplate, the default python import path is like,

$ ./python.manifest -c "import sys; print '\n'.join(sys.path).strip()"
/usr/lib/python2.7
/usr/lib/python2.7/plat-x86_64-linux-gnu
/usr/lib/python2.7/lib-tk
/usr/lib/python2.7/lib-old
/usr/lib/python2.7/lib-dynload
/usr/local/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages

I don't know why this path is different with the local python path (without the local
directory /home/umr/.local/lib/python2.7/site-packages). So I added a line in python.manifest.tample ,

loader.env.PYTHONPATH = /usr/lib/python2.7:/usr/lib/python2.7/plat-x86_64-linux-gnu:/usr/lib/python2.7/lib-tk:/usr/lib/python2.7/lib-old:/usr/lib/python2.7/lib-dynload:/home/umr/.local/lib/python2.7/site-packages:/usr/local/lib/python2.7/dist-packages:/usr/lib/python2.7/dist-packages

The local python path was loaded, but the third parties lib inside the local directory still cannot be imported. I also tried to execute pip to lookup modules, but the code throws an assert error,

$ ./python.manifest -c "import sys; print '\n'.join(sys.path).strip()"
/usr/lib/python2.7
/usr/lib/python2.7/plat-x86_64-linux-gnu
/usr/lib/python2.7/lib-tk
/usr/lib/python2.7/lib-old
/usr/lib/python2.7/lib-dynload
/home/umr/.local/lib/python2.7/site-packages
/usr/local/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages


$ ./python.manifest -c "import datrie"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named datrie

$ ./python.manifest -c "import pip"
assert failed fs/shim_namei.c:297 start->state & DENTRY_ISDIRECTORY (value:0)
Trace/breakpoint trap (core dumped)

Does anyone know the solution? Thanks.

@nyannko nyannko closed this as completed Oct 3, 2018
@chiache
Copy link
Contributor

chiache commented Oct 3, 2018

Sorry for the late reply. Is this issue resolved?

@nyannko
Copy link
Author

nyannko commented Oct 3, 2018

Yeah, I move local packages to the global directory.

@tarikova
Copy link

hi @nyannko: apologies for pinging on a resolved issue. I am wondering what libraries you were trying to import? I am currently trying to run numpy and it fails (details here: #267). Wondering if you could help.

Thanks a lot.

@nyannko
Copy link
Author

nyannko commented Oct 24, 2018

Hi @tarikova , I cannot import numpy, here is my output:

$ ./python.manifest -c "import enum"
$ ./python.manifest -c "import twisted"
$ ./python.manifest -c "import cryptography"
$ ./python.manifest -c "import numpy"
Internal memory fault at 0x0 (IP = +0xa206f, VMID = 1813063638, TID = 1)
Trace/breakpoint trap (core dumped)
$ ./python.manifest -c "import networkx"
Internal memory fault at 0x0 (IP = +0xa206f, VMID = 1820010471, TID = 1)
Trace/breakpoint trap (core dumped)

@tarikova
Copy link

Thanks for your quick response @nyannko. I was able to run numpy and various other libraries. Please check #267

@tarikova
Copy link

And I know you have already closed the issue, but one way to solve it is to add path using sys library.
I do the following:

import sys
sys.path.append('/home/<USER_NAME>/.local/lib/python2.7/site-packages')

@ihepburn
Copy link

Another method is to set manifest file.
#267 (comment) gives a correct configuration for sys.path, and
the path in sys.path should be mounted and allowed at the same time.

In order to load /home/umr/.local/lib/python2.7/site-packages suitably:

  1. Mount the home dir:
fs.mount.home.type = chroot
fs.mount.home.path = /home
fs.mount.home.uri = file:/home
  1. Authorize the path:
    /home/umr/.local/lib/python2.7/site-packages

@kanakraju73
Copy link

kanakraju73 commented Mar 15, 2019

Hi @nyannko @tarikova

I'm facing similar issues while importing numpy.

$ ./python.manifest.sgx -c "import numpy"
Internal memory fault at 0x0 (IP = +0x1e5c6, VMID = 134455687, TID = 1)
^CIllegal instruction executed in enclave

none of the above ideas worked for me.

can you share your manifest here. Thanks in advance.

@ihepburn
Copy link

ihepburn commented Mar 18, 2019 via email

@kanakraju73
Copy link

Hi @ihepburn ,

It seems like you forgot to attach manifest. Could you share it now?

Thanks,
Kanak

@ihepburn
Copy link

@kanakraju73, You should remove the .txt suffix in attachments. The numpytest is a Python NumPy test script.

python.manifest.txt

numpytest.py.txt

@kanakraju73
Copy link

Thanks for the prompt response. It's working for me. Thanks a ton.

Kanak.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants