entrezpy can be installed or included into your own pipeline using two approaches: PyPi or Append to sys.path.


  • Python version >= 3.6

  • Python Standard Library :

    The standard library should be installed with Python. Just in case, these modules from the Python Standard Library are required:

    • base64
    • io
    • json
    • logging
    • math
    • os
    • queue
    • random
    • socket
    • sys
    • threading
    • time
    • urllib
    • uuid
    • xml.etree.ElementTree

Test your Python version

Test if we have at least Python 3.6 :

$ python
>>> import sys
>>> sys.version_info
>>> sys.version_info(major=3, minor=6, micro=6, releaselevel='final', serial=0)
                         ^        ^


Install entrezpy via PyPi and check:

$ pip install entrezpy --user

Test if we can import entrezpy:

$ python
>>> import entrezpy

Append to sys.path

Add entrezpy to your pipeline via sys.path. This requires to clone the source code adjusting sys.path.

Assuming following directory structure where entrezpy was cloned into include:

$ git clone project_root/include

|-- src
|   `--
`-- include
    `-- entrezpy
        `-- src
            `-- entrezpy
                `-- efetch

Importing the module efetcher in by adjust sys.path in project_root/src/

sys.path.insert(1, os.path.join(sys.path[0], '../include/entrezpy/src'))
import entrezpy.efetch.efetcher

ef = entrezpy.efetch.efetcher.Efetcher('toolname', 'email')

Test entrezpy

Run the examples in the git repository in entrezpy/examples, e.g:

$ ./path/to/entrezpy/examples/ --email you@email

To adjust the examples for testing an installation via PyPi, remove the sys.path line in the examples prior to invoking them, e.g.

for i in entrezpy/examples/*.py; do                 \
  fname=$(basename $i | sed 's/\.py/\'); \
  sed '/sys.path.insert/d' $i > $fname;             \
  chmod +x $fname;                                  \

The examples print the results onto the standard output and additional information onto standard error. Currently, we propose to run the examples and redirecting standard error to a file. For example, testing efetch, run examples/ as follows:

./examples/ --email you@email 2> efetch.stderr

efetch.stderr can be monitored as follows:

tail -f efetch.stderr