0

I compile using pyinstaller -F ./parser.spec.
Then I run the program with ./dist/parser and get this error:

Traceback (most recent call last):
  File "<string>", line 21, in <module>
ImportError: No module named 'rethinkdb'
parser returned -1

I tried to create a hook file, but to be honest I really feel like I have no idea what I'm doing.

rethinkdb is in hiddenimports but pyparser doesn't throw any errors at me indicating what might be wrong.

parser
#!/usr/bin/env python
...
import rethinkdb
...
parser.spec
...
a = Analysis(
    ['parser'],
    pathex=[os.path.realpath('./env/lib/python3.3/site-packages/')],
    binaries=None,
    datas=added_files,
    hiddenimports=['rethinkdb'],
    hookspath=[os.path.realpath('./hooks')],
    runtime_hooks=None,
    excludes=None,
    win_no_prefer_redirects=None,
    win_private_assemblies=None,
    cipher=block_cipher
)
...
hooks/hook-rethinkdb.py
hiddenimports = [
    'ssl',
    'cPickle',
    'pickle',
    'itertools',
    'multiprocessing',
    'builtins',
    'rethinkdb',
    'rethinkdb.ast',
    'rethinkdb.errors',
    'rethinkdb.net',
    'rethinkdb.ql2_pb2',
    'rethinkdb.query',
    'rethinkdb.version',
]
Community
  • 1
  • 1
demux
  • 4,544
  • 2
  • 32
  • 56
  • What's the advantage of using `pyinstaller`? – dalanmiller Jan 26 '16 at 20:09
  • I bundle the application as a standalone command line program that can be placed in `/usr/local/bin` without dependencies. Some people in the company cannot and should not be expected to know about git, python, virtualenvs, etc... – demux Jan 26 '16 at 23:29
  • @dalanmiller, on a related issue, why is the `python-driver` for `rethinkdb` not on github? I think I've figured out the issue. I'd like to fork the driver and fix the problem, but since the driver is not on github, I guess I'll have to create a new repo. – demux Jan 27 '16 at 00:18
  • 1
    Totally understood @demux and completely 100% agree. It is actually on Github! But it's nested in the RethinkDB repo => https://github.com/rethinkdb/rethinkdb/tree/next/drivers/python. Also, if you're on Slack, we have a #driver-dev channel if you need assistance => http://slack.rethinkdb.com. – dalanmiller Jan 27 '16 at 00:41

1 Answers1

0

I was having the same kind of trouble with an application I was making but it had an easy fix. I am not sure if it will work for you but I would at least try it because it is really easy. Instead of editing the spec file try running this in the command line:

pyinstaller --paths=C:/Users/.../Python34/Lib/site-packages filename.py

Obviously change the path to the correct path for your computer. Hopefully this helps if not I hope you can find an answer.

Mark Skelton
  • 3,663
  • 4
  • 27
  • 47
  • Thank you, but this will not do. the python path of my virtual environment is already in the `.spec` file, even though it doesn't need to be there. All other packages get included. It's just rethinkdb that is missing. – demux Jan 24 '16 at 16:29