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.
2 Answers 2
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.
1 Comment
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?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.