I'll preface this question by saying that I've barely used python before, and never before on Mac OS, so I am fully ready to accept that I'm probably doing something rather silly!
I've been sent two python projects, one of which I need to run. When I open the project I'm interested in (in TextWrangler), and run, I get the following error:
context.py:16: ImportError: No module named fetch_command
Well.. fetch_command is a module in the other program, which is in the same directory ( /Users/myname
) as the program that I am trying to run. The (scant documentation for the applications suggests:
" I wouldn't try installing into your python installation dirs, I'd install to some home directory or prefix and set up your PYTHONPATH and PATH (or use virtualenv) "
and so I have tried (and succeeded - I've tested by calling echo $PATH
and echo $PYTHONPATH
) adding Users/myname
to PATH and PYTHONPATH. This did nothing. I then tried adding /Users/myname/other_python_app/src
to PATH and PYTHONPATH, but this also hasn't worked. Anyone know what I'm doing wrong..?
Thanks a lot in advance!
Ah, I understand the issue now. It's not that you can't find it in your Python project, but rather in your text editor. There should be a menu entry to set your PYTHONPATH from within TextWrangler (I tried looking for the documentation but the site seems to be down). Oftentimes, these editors don't respect the PYTHONPATH variable or do so only on restart.
This is a bit of a hack in your case, but try adding an empty file __init__.py
so Python knows that this directory contains a module.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.