How to add modules from a custom repository that isn't a package? python
Question: I have tried to use `sys.path.append()` with `os.getcwd()` but it didn't work.

The source was from [**here**](https://github.com/alvations/DLTK) and I've
downloaded and extracted them as such:

    
    
    alvas@ubi:~/test$ wget https://github.com/alvations/DLTK/archive/master.zip
    alvas@ubi:~/test$ tar xvzf master.zip
    
    alvas@ubi:~/test$ cd DLTK-master/; ls
    dltk
    
    alvas@ubi:~/test/DLTK-master$ cd dltk/; ls
    tokenize
    alvas@ubi:~/test/DLTK-master/dltk$ cd tokenize/; ls
    abbrev.lex                         jwordsplitter-3.4.jar  rbtokenize.pl
    banana-split-standalone-0.4.0.jar  koehn_senttokenize.pl  splicer.py
    igerman98_all.xml                  koehn_wordtokenize.pl  tokenizer.py
    __init__.py                        nonbreaking_prefix.de
    
    alvas@ubi:~/test/DLTK-master/dltk/tokenize$ cat __init__.py
    from tokenizer import punct_tokenize, rb_tokenize 
    from tokenizer import koehn_tokenize, deupunkt_tokenize
    from splicer import jwordsplitter, jwordsplitteralvas
    

Those are the functions I want to access from the `~/text/` directory, e.g.
the `koehn_tokenize` function. But i can't seem to add the modules/functions
into my python interpreter.

    
    
    alvas@ubi:~/test$ wget https://github.com/alvations/DLTK/archive/master.zip
    alvas@ubi:~/test$ tar xvzf master.zip
    alvas@ubi:~/test$ python
    Python 2.7.5+ (default, Sep 19 2013, 13:48:49) 
    [GCC 4.8.1] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import sys, os
    >>> os.getcwd()
    '/home/alvas/test'
    >>> sys.path.append(os.path.join(os.getcwd(),'DLKT-master/dltk'))
    ['','/usr/local/lib/python2.7/dist-packages/...', ...,'/home/alvas/test/DLKT-master/dltk']
    >>>
    >>> import dltk
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ImportError: No module named dltk
    >>>
    >>> from dltk.tokenize import koehn_tokenize
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ImportError: No module named dltk.tokenize
    

**From the python interpreter at`~/test/` directory, how can I access the the
`dltk.tokenize` module?**

The functions works if it `cd` into `~/test/DLTK-master/dltk/tokenize`:

    
    
    alvas@ubi:~/test$ cd DLTK-master/dltk/tokenize/
    alvas@ubi:~/test/DLTK-master/dltk/tokenize$ python
    Python 2.7.5+ (default, Sep 19 2013, 13:48:49) 
    [GCC 4.8.1] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from __init__ import koehn_tokenize
    >>>
    

But I **DO NOT** want to `cd` into the `~/test/DLTK-master/dltk/tokenize`
before using the python interpreter. I need to somehow append the
module/functions within python.


Answer: If `master.zip` would contain `dltk/__init__.py`, `dltk/tokenize/__init__.py`
then you could try to add it to `sys.path` directly:

    
    
    import sys; sys.path.append('master.zip')
    from dltk.tokenize import koehn_tokenize
    

* * *

> From the python interpreter at `~/test/` directory, how can I access the the
> `dltk.tokenize` module?

Just add `~/test/DLTK-master` directory to `sys.path`:

    
    
    import sys; sys.path.append('DLTK-master')
    from dltk.tokenize import koehn_tokenize
    

