Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sys.path not being correctly set up #64

Closed
gsnedders opened this issue Mar 29, 2016 · 0 comments
Closed

sys.path not being correctly set up #64

gsnedders opened this issue Mar 29, 2016 · 0 comments

Comments

@gsnedders
Copy link
Contributor

Given the foo/bar.py with import subdir and an empty foo/subdir/__init__.py, running python foo/bar.py exits with no exceptions printed and with an exit code of zero, however python -m vmprof foo/bar.py throws ImportError:

Traceback (most recent call last):
  File "/opt/pypy/lib-python/2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/opt/pypy/lib-python/2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/mnt/home-extra/gsnedders/Documents/other-projects/csswg-testsuite-pypy-env/site-packages/vmprof/__main__.py", line 69, in <module>
    main()
  File "/mnt/home-extra/gsnedders/Documents/other-projects/csswg-testsuite-pypy-env/site-packages/vmprof/__main__.py", line 58, in main
    runpy.run_path(args.program, run_name='__main__')
  File "/opt/pypy/lib-python/2.7/runpy.py", line 240, in run_path
    return _run_module_code(code, init_globals, run_name, path_name)
  File "/opt/pypy/lib-python/2.7/runpy.py", line 82, in _run_module_code
    mod_name, mod_fname, mod_loader, pkg_name)
  File "/opt/pypy/lib-python/2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "foo/bar.py", line 1, in <module>
    import subdir
ImportError: No module named subdir

This seems to be down to sys.path[0] differing between the two (sys.path[1:] is equal): without vmprof, it's the path to ./foo; with vmprof, it's '').

gsnedders added a commit to gsnedders/vmprof-python that referenced this issue Mar 29, 2016
@fijal fijal closed this as completed in #65 Apr 1, 2016
fijal added a commit that referenced this issue Apr 1, 2016
Fix #64: set sys.path to match `python foo.py` behaviour
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant