The Python module does not work (cannot be imported) even after including it in the PATH variable

I have one testing module that I want to use to test Android. I have files, but there is no installation file for it, so I added the module to the PATH variable, even then it does not work. I am trying to import it.

Any way to make it work. Should I paste them only into the Python folder (and that is the location of the Python file). On Windows, I use to paste all files into a Python folder, and everything works fine. Here in Ubuntu, I cannot find the location, so I added it to PATH.

Anyway! Any help is appreciated.

Greetings

Some details: Python version: 2.7.2, Ubuntu 11.10 OS, the Python module is in the file / folder format without the setup.py file for installation, the module location is already in the PATH variable, everything else in Python works next to this module, the same worked on Windows XP with Python 2.7.2 after copying.

+4
source share
2 answers

PATH for executables, PYTHONPATH for Python modules.

You can also run 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 are importing.

The normal location of Python modules is in /usr/lib/pythonX.X/site-packages . To install the material as a virtualenv user is excellent.

+7
source

You can add the __init__.py file without any content to the directory you want to import.

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

+1
source

Source: https://habr.com/ru/post/1394788/


All Articles