7

I have one testing module that I want to use for android testing. I have the files but there is no installation file for it, so I added the module to PATH variable, even then it doesn't work I try to import it.

Any way to make it work. Do I have to paste them in Python folder only (and what it the Python file location). In windows, I use to paste all the files in Python folder and everything works perfectly fine. Here in Ubuntu I'm not able to find the location so I added it in PATH.

Any way out! Any help is appreciated.

Cheers

Some details: Python version: 2.7.2, Ubuntu 11.10 OS, Python module is in file/folder format with no "setup.py" file to install, Location of module already in PATH variable, Everything else in Python is working beside that module, same worked in Windows XP with Python 2.7.2 after copy pasting.

asked Feb 4, 2012 at 19:00

2 Answers 2

8

PATH is for executables, PYTHONPATH is for Python modules.

You can also start your script with:

import sys
sys.path.append('/path/to/directory')
import your_module

Where /path/to/directory/your_module.py is the file you're importing.

The normal location for Python modules is in /usr/lib/pythonX.X/site-packages. For installing stuff as a user virtualenv is great.

answered Feb 4, 2012 at 19:14
Sign up to request clarification or add additional context in comments.

1 Comment

regards the site-packages folder - what files do I need to plonk in there in order to refer to them as part of an environment? Or is it more complicated than that?
5

You can add a __init__.py file without any content to the directory which yo want to import.

The init.py files are required to make Python treat the directories as containing packages; this is done to prevent directories with a common name, such as string , from unintentionally hiding valid modules that occur later (deeper) on the module search path.

answered Mar 22, 2017 at 7:11

1 Comment

It worked like hell man. So sad to see your answer with 0 upvotes

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.