1

I'm running this python script on a remote machine and asks for pyfits, which is technically installed on the machine, but python doesn't find it.

I've already tried adding the supposed directory it's installed in to my paths (I have access to the folder too) by the sys.path.append('folder') method. But it still doesn't find it.

Here's some thought process to illustrate:

The user who installed the modules has all the source at "/otheruser/code/pyfits" so I've tried adding that folder or any folder with pyfits and an init file (that I have access to) in it, without success.

So my main questions are:

Should I be looking elsewhere for the module? Should I install the modules again as --myuser? or should I mess with the site-packages? If so does one add the module there?

1
  • Can you post a sample of your code to modify sys.path and attempt to load the module, including the paths you're using? I can think of a number of possibilities regarding what could be going wrong but doing that might rule some out. Aug 24, 2013 at 1:38

1 Answer 1

0

According to the PyFITS documentation, it looks like the actual modules are installed in lib/python or possibly lib/python<version>/site-packages (depending on the flags they used for the install) under the top-level PyFITS install directory. So, normally you'd want to do something like this:

sys.path.append(r'/otheruser/code/pyfits/lib/python')

# Might be sys.path.append(r'/otheruser/code/pyfits/lib/python2.7/site-packages')
# or something similar

import numpy
import pyfits

If you are able to read the contents of the directory you appended and its subdirectories, you should be good to go.

However, as I mentioned in my comment on your original question, you might want to edit your question to include the actual code you're using to do this, since any problem might be easier to guess that way.

Sources of difficulty might be:

  1. Adding a directory to your sys.path that doesn't point to the actual modules.

  2. Absence of an __init__.py file in the module directory.

  3. Not having permissions to view folders' contents or read the enclosed files.

  4. Problems with Python's string handling screwing your path up somehow (like not using raw mode and not adequately escaping backslashes when using windows paths containing backslashes.)

  5. Something overwriting your sys.path before your import occurs.

  6. A typo.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.