`lpad init` returns NameError


I’m trying to set up my first Launchpad with a remote MongoDB (the free one from MongoDB Atlas). I type lpad init, enter everything requested, and then I get an error message:

~ lpad init
Please supply the following configuration values
(press Enter if you want to accept the defaults)

Enter host parameter. (default: localhost). Example: 'localhost' or 'mongodb+srv://CLUSTERNAME.mongodb.net': mongodb+srv://[redacted].mongodb.net
Enter port parameter. (default: 27017). :
Enter name parameter. (default: fireworks). Database under which to store the fireworks collections:
Enter username parameter. (default: None). Username for MongoDB authentication: [redacted]
Enter password parameter. (default: None). Password for MongoDB authentication: [redacted]
Enter ssl_ca_file parameter. (default: None). Path to any client certificate to be used for Mongodb connection:
Enter authsource parameter. (default: None). Database used for authentication, if not connection db. e.g., for MongoDB Atlas this is sometimes 'admin'.:
Traceback (most recent call last):
  File "/home/benwibking/anaconda3/bin/lpad", line 33, in <module>
    sys.exit(load_entry_point('FireWorks', 'console_scripts', 'lpad')())
  File "/home/benwibking/fireworks/fireworks/scripts/lpad_run.py", line 1551, in lpad
  File "/home/benwibking/fireworks/fireworks/scripts/lpad_run.py", line 191, in init_yaml
    lp = LaunchPad.from_dict(doc)
  File "/home/benwibking/fireworks/fireworks/core/launchpad.py", line 295, in from_dict
    return LaunchPad(
  File "/home/benwibking/fireworks/fireworks/core/launchpad.py", line 213, in __init__
    self.connection = MongoClient(
  File "/home/benwibking/anaconda3/lib/python3.9/site-packages/pymongo/mongo_client.py", line 704, in __init__
    res = uri_parser.parse_uri(
  File "/home/benwibking/anaconda3/lib/python3.9/site-packages/pymongo/uri_parser.py", line 467, in parse_uri
    python_path = sys.executable or "python"
NameError: name 'sys' is not defined

I’m using Fireworks 2.0.2 installed manually from the Git repository.

Welcome, Ben.
I don’t know the root cause of this problem but the local problem is the lpad code somehow didn’t import sys before trying to use the sys module.

sys is built-in to Python so it should always be available, but just to rule out potential problems in the Python installation, try running this from the shell:

python -c 'import sys; print(sys.executable)'

That should print the full path to Python’s executable program.

Then maybe try uninstalling Fireworks and installing it from the Pypi server like this:

pip install FireWorks

or maybe selecting an earlier release, like this:

pip install FireWorks==2.0.1


pip install FireWorks==1.9.7

Unfortunately the FireWorks changelog is no longer maintained. We need to read the commit log to find out what changed in each release.

Personally, I haven’t tried any releases since 1.9.7. Good luck!

I think this issue was resolved in the master branch. Try pip install git+https://github.com/materialsproject/fireworks.git until the new version is released.

I get the same error as before after installing from git.

My python installation works:

$ python -c ‘import sys; print(sys.executable)’