0

I have installed the opensource version of pymol on windows (https://github.com/schrodinger/pymol-open-source).

To run pymol, I can open a python3.8 command prompt on windows and type the following:

import pymol
pymol.finish_launching()

This launches the pymol gui.

I'd now like to create a simple python script so that I can click the script (or convert to a windows executible using for example pyinstaller), however if I put the above commands in a script pymol.py and then run with:

python pymol.py

where python points to python3.8 I get the following error:

AttributeError: partially initialize module 'pymol' has no attribute 'finish_launching' most likely due to a circular import.

Why does this work on the command line python but not in a script and how can I fix this so the script runs and can be converted to a windows executible?

218
  • 1,754
  • 7
  • 27
  • 38
  • 1
    Try renaming the your script to something like `start_pymol.py` because Python tries to find `fnish_launching` in your script and not from the module itself. https://stackoverflow.com/questions/36250353/importing-installed-package-from-script-raises-attributeerror-module-has-no-at – Maximilian Peters May 22 '20 at 15:53
  • 1
    Thanks. That fixed the problem. I had actually tried renaming the script, but fell into the second trap on the link you posted, that there was a left-over file with the name 'pymol' that the script was finding even though the script itself had a different name. – 218 May 23 '20 at 08:01
  • Does this answer your question? [Importing installed package from script raises "AttributeError: module has no attribute" or "ImportError: cannot import name"](https://stackoverflow.com/questions/36250353/importing-installed-package-from-script-raises-attributeerror-module-has-no-at) – Maximilian Peters May 23 '20 at 19:05

0 Answers0