openmm
openmm copied to clipboard
Issue when trying to import openmm from a fresh install from conda-forge: _openmm: The specified module could not be found.
I think that I'm finding a similar issue when using the current conda-forge build. I'm getting this import error:
ImportError: DLL load failed while importing _openmm: The specified module could not be found.
This occurs both with importing from jupyter notebook and when using command in the conda environment where its installed:
python -m openmm.TestInstallation
I verified that the path to the dir containing_openmm.cp38-win_amd64.pyd is in the path env variable, but I still can't get a proper import
I also tried to install deepchem in the hopes that the dependencies would trigger a version change of openmm, but to no avail.
Any ideas?
edit: I'm using Win10 using conda as my env manager and installed openmm package from conda-forge channel
It sounds like something is broken in your conda environment. Could you create a clean environment, install OpenMM into it, and see if it works? Something like this.
conda create -c conda-forge --name openmm python=3.9 openmm
conda activate openmm
python -m openmm.testInstallation
This is how I installed openmm initially. New environment, no cloning, no packages besides openmm.
On Fri, May 27, 2022, 4:58 PM Peter Eastman @.***> wrote:
It sounds like something is broken in your conda environment. Could you create a clean environment, install OpenMM into it, and see if it works? Something like this.
conda create -c conda-forge --name openmm python=3.9 openmm conda activate openmm python -m openmm.testInstallation
— Reply to this email directly, view it on GitHub https://github.com/openmm/openmm/issues/3618#issuecomment-1140109333, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXTWV6J7SY44C2XWYRKB4JTVMFOQ7ANCNFSM5XFVTX3Q . You are receiving this because you authored the thread.Message ID: @.***>
Can you try exactly the commands I posted and provide the complete output?
Went the extra mile and removed the package from bugged env and base, recreated env according to your post and still persists.
On Fri, May 27, 2022, 5:04 PM Peter Eastman @.***> wrote:
Can you try exactly the commands I posted and provide the complete output?
— Reply to this email directly, view it on GitHub https://github.com/openmm/openmm/issues/3618#issuecomment-1140111366, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXTWV6OP7TLDSW6INJECMS3VMFPJPANCNFSM5XFVTX3Q . You are receiving this because you authored the thread.Message ID: @.***>
I just tried the install in my personal machine, was able to repro on win11
Can you please provide the complete output from the sequence of commands I posted?
You'll have to trust me when I say that I copied the shell commands that you posted, but I've spent the better part of this morning uninstalling miniconda and installing anaconda to have a clean slate to run on. This is the output after the terminal crashed.
(base) PS C:\WINDOWS\system32> conda activate openmm
(openmm) PS C:\WINDOWS\system32> python -m openmm.TestInstallation
Traceback (most recent call last):
File "C:\Users\Carter\anaconda3\envs\openmm\lib\runpy.py", line 188, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "C:\Users\Carter\anaconda3\envs\openmm\lib\runpy.py", line 111, in _get_module_details
__import__(pkg_name)
File "C:\Users\Carter\anaconda3\envs\openmm\lib\site-packages\openmm\__init__.py", line 19, in <module>
from openmm.openmm import *
File "C:\Users\Carter\anaconda3\envs\openmm\lib\site-packages\openmm\openmm.py", line 13, in <module>
from . import _openmm
ImportError: DLL load failed while importing _openmm: The specified module could not be found.
(openmm) PS C:\WINDOWS\system32>
You omitted the output from conda create
, which would give information about what's installed and where. Could you post the output of the following commands?
conda list
dir C:\Users\Carter\anaconda3\envs\openmm\lib\site-packages\openmm
One way or another, Python is failing to load the DLL for the openmm
module. That's either because 1) the DLL isn't present (the dir
command will tell us that), 2) it's incompatible with the Python it's installed in (that shouldn't ever happen, but the output of conda list
will give information), or 3) it's failing to find some other library it depends on.
` (base) PS C:\WINDOWS\system32> conda create -n openmm -c conda-forge openmm python=3.9 -y Collecting package metadata (current_repodata.json): done Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source. Collecting package metadata (repodata.json): done Solving environment: done
Package Plan
environment location: C:\Users\canedca1\Miniconda3\envs\openmm
added / updated specs:
- openmm
- python=3.9
The following packages will be downloaded:
package | build |
---|---|
libzlib-1.2.12 | h8ffe710_0 67 KB conda-forge |
numpy-1.22.4 | py39h0948cea_0 6.1 MB conda-forge |
openmm-7.6.0 | py39h6dc0912_0 10.5 MB conda-forge |
python-3.9.13 | hcf16a7b_0_cpython 17.9 MB conda-forge |
setuptools-62.3.2 | py39hcbf5309_0 1.4 MB conda-forge |
tzdata-2022a | h191b570_0 121 KB conda-forge |
Total: 36.0 MB
The following NEW packages will be INSTALLED:
bzip2 conda-forge/win-64::bzip2-1.0.8-h8ffe710_4 ca-certificates conda-forge/win-64::ca-certificates-2022.5.18.1-h5b45459_0 intel-openmp conda-forge/win-64::intel-openmp-2022.1.0-h57928b3_3787 khronos-opencl-ic~ conda-forge/win-64::khronos-opencl-icd-loader-2022.01.04-h8d14728_0 libblas conda-forge/win-64::libblas-3.9.0-14_win64_mkl libcblas conda-forge/win-64::libcblas-3.9.0-14_win64_mkl libffi conda-forge/win-64::libffi-3.4.2-h8ffe710_5 liblapack conda-forge/win-64::liblapack-3.9.0-14_win64_mkl libzlib conda-forge/win-64::libzlib-1.2.12-h8ffe710_0 mkl conda-forge/win-64::mkl-2022.0.0-h0e2418a_796 numpy conda-forge/win-64::numpy-1.22.4-py39h0948cea_0 openmm conda-forge/win-64::openmm-7.6.0-py39h6dc0912_0 openssl conda-forge/win-64::openssl-3.0.3-h8ffe710_0 pip conda-forge/noarch::pip-22.1.1-pyhd8ed1ab_0 python conda-forge/win-64::python-3.9.13-hcf16a7b_0_cpython python_abi conda-forge/win-64::python_abi-3.9-2_cp39 setuptools conda-forge/win-64::setuptools-62.3.2-py39hcbf5309_0 sqlite conda-forge/win-64::sqlite-3.38.5-h8ffe710_0 tbb conda-forge/win-64::tbb-2021.5.0-h2d74725_1 tk conda-forge/win-64::tk-8.6.12-h8ffe710_0 tzdata conda-forge/noarch::tzdata-2022a-h191b570_0 ucrt conda-forge/win-64::ucrt-10.0.20348.0-h57928b3_0 vc conda-forge/win-64::vc-14.2-hb210afc_6 vs2015_runtime conda-forge/win-64::vs2015_runtime-14.29.30037-h902a5da_6 wheel conda-forge/noarch::wheel-0.37.1-pyhd8ed1ab_0 xz conda-forge/win-64::xz-5.2.5-h62dcd97_1
Downloading and Extracting Packages python-3.9.13 | 17.9 MB | | 100% setuptools-62.3.2 | 1.4 MB | | 100% libzlib-1.2.12 | 67 KB | | 100% numpy-1.22.4 | 6.1 MB | | 100% tzdata-2022a | 121 KB | | 100% Preparing transaction: done Verifying transaction: done Executing transaction: - "By downloading and using the CUDA Toolkit conda packages, you accept the terms and conditions of the CUDA End User License Agreement (EULA): https://docs.nvidia.com/cuda/eula/index.html"
done
To activate this environment, use
conda activate openmm
To deactivate an active environment, use
$ conda deactivate
(base) PS C:\WINDOWS\system32> conda activate openmm (openmm) PS C:\WINDOWS\system32> conda list packages in environment at C:\Users\canedca1\Miniconda3\envs\openmm:
Name Version Build Channel bzip2 1.0.8 h8ffe710_4 conda-forge ca-certificates 2022.5.18.1 h5b45459_0 conda-forge cudatoolkit 11.7.0 ha6f8bbd_10 conda-forge fftw 3.3.10 nompi_h77347bd_102 conda-forge intel-openmp 2022.1.0 h57928b3_3787 conda-forge khronos-opencl-icd-loader 2022.01.04 h8d14728_0 conda-forge libblas 3.9.0 14_win64_mkl conda-forge libcblas 3.9.0 14_win64_mkl conda-forge libffi 3.4.2 h8ffe710_5 conda-forge liblapack 3.9.0 14_win64_mkl conda-forge libzlib 1.2.12 h8ffe710_0 conda-forge mkl 2022.0.0 h0e2418a_796 conda-forge numpy 1.22.4 py39h0948cea_0 conda-forge openmm 7.6.0 py39h6dc0912_0 conda-forge openssl 3.0.3 h8ffe710_0 conda-forge pip 22.1.1 pyhd8ed1ab_0 conda-forge python 3.9.13 hcf16a7b_0_cpython conda-forge python_abi 3.9 2_cp39 conda-forge setuptools 62.3.2 py39hcbf5309_0 conda-forge sqlite 3.38.5 h8ffe710_0 conda-forge tbb 2021.5.0 h2d74725_1 conda-forge tk 8.6.12 h8ffe710_0 conda-forge tzdata 2022a h191b570_0 conda-forge ucrt 10.0.20348.0 h57928b3_0 conda-forge vc 14.2 hb210afc_6 conda-forge vs2015_runtime 14.29.30037 h902a5da_6 conda-forge wheel 0.37.1 pyhd8ed1ab_0 conda-forge xz 5.2.5 h62dcd97_1 conda-forge (openmm) PS C:\WINDOWS\system32> dir "C:\Users\canedca1\Miniconda3\envs\openmm\Lib\site-packages\openmm"
Directory: C:\Users\canedca1\Miniconda3\envs\openmm\Lib\site-packages\openmm
Mode LastWriteTime Length Name
d----- 5/31/2022 7:57 AM app d----- 5/31/2022 7:57 AM unit d----- 5/31/2022 7:57 AM pycache -a---- 8/27/2021 10:47 AM 11558 amd.py -a---- 8/27/2021 10:50 AM 10159 mtsintegrator.py -a---- 8/27/2021 10:58 AM 792342 openmm.py -a---- 8/27/2021 10:50 AM 4459 testInstallation.py -a---- 8/27/2021 10:51 AM 3325 vec3.py -a---- 5/31/2022 7:57 AM 331 version.py -a---- 8/27/2021 10:59 AM 3213824 _openmm.cp39-win_amd64.pyd -a---- 8/27/2021 10:47 AM 1437 init.py
(openmm) PS C:\WINDOWS\system32> python -m openmm.TestInstallation
Traceback (most recent call last):
File "C:\Users\canedca1\Miniconda3\envs\openmm\lib\runpy.py", line 188, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "C:\Users\canedca1\Miniconda3\envs\openmm\lib\runpy.py", line 111, in get_module_details
import(pkg_name)
File "C:\Users\canedca1\Miniconda3\envs\openmm\lib\site-packages\openmm_init.py", line 19, in
That's the full output from start to finish, pardon the interpreted formatting. The persistent error is occurring at the import of the _openmm module.
I've since tried a conda-forge install on a linux box and I'm able to run simulationPDB.py just fine with no issues, but I'd prefer to be able to run my sims natively in windows.
I'm not sure what's causing it. The file is there, so that's not the problem. And the version it installed looks appropriate for your environment.
I searched for that error message and found a lot of people reporting similar problems with many different packages. Some people were able to fix it by uninstalling and reinstalling packages, but that doesn't seem to be the case for you. Other people said the only fix was to uninstall and reinstall anaconda. See for example https://stackoverflow.com/questions/41365446/how-to-resolve-importerror-dll-load-failed-on-python. A lot of the reports seem to be with anaconda. I don't know whether that's just a coincidence or not. I usually use miniconda, though it might have the same issues.
Getting a similar issue for what it is worth. Not sure if a conda issue or something else. Adding the below in case it helps anyone. Fresh install on 5-27-2022 via conda, test install works:
(openmm) PS C:\Users\robot> python -m openmm.testInstallation
OpenMM Version: 7.7
Git Revision: 130124a3f9277b054ec40927360a6ad20c8f5fa6
There are 4 Platforms available:
1 Reference - Successfully computed forces
2 CPU - Successfully computed forces
3 CUDA - Successfully computed forces
4 OpenCL - Successfully computed forces
Median difference in forces between platforms:
Reference vs. CPU: 6.32058e-06
Reference vs. CUDA: 6.72681e-06
CPU vs. CUDA: 7.30902e-07
Reference vs. OpenCL: 6.76294e-06
CPU vs. OpenCL: 7.72245e-07
CUDA vs. OpenCL: 2.65269e-07
All differences are within tolerance.
Going through the documentation myself: Running this example works fine:
from simtk.openmm.app import *
from simtk.openmm import *
from simtk.unit import *
from sys import stdout
pdb = PDBFile('test1cpy_pdbfixed_moved.pdb')
forcefield = ForceField('amber99sb.xml', 'tip3p.xml')
system = forcefield.createSystem(pdb.topology)
integrator = LangevinIntegrator(300*kelvin, 1/picosecond, 0.002*picoseconds)
simulation = Simulation(pdb.topology, system, integrator)
simulation.context.setPositions(pdb.positions)
simulation.minimizeEnergy()
simulation.reporters.append(PDBReporter('test1cpy_pdbfixed_moved_openmm.pdb', 1000))
simulation.reporters.append(StateDataReporter(stdout, 1000, step=True,
potentialEnergy=True, temperature=True))
simulation.step(10000)
But running the example from 03_model_building_editing 4.6 gives the same DLL issue:
from openmm.app import *
from openmm import *
from openmm.unit import *
print('Loading...')
pdb = PDBFile('test1cpy_pdbfixed_moved.pdb')
forcefield = ForceField('amber99sb.xml', 'tip3p.xml')
modeller = Modeller(pdb.topology, pdb.positions)
print('Adding hydrogens...')
modeller.addHydrogens(forcefield)
print('Adding solvent...')
modeller.addSolvent(forcefield, padding=1*nanometer)
print('Minimizing...')
system = forcefield.createSystem(modeller.topology, nonbondedMethod=PME)
integrator = VerletIntegrator(0.001*picoseconds)
simulation = Simulation(modeller.topology, system, integrator)
simulation.context.setPositions(modeller.positions)
simulation.minimizeEnergy(maxIterations=100)
print('Saving...')
positions = simulation.context.getState(getPositions=True).getPositions()
PDBFile.writeFile(simulation.topology, positions, open('output_solvent.pdb', 'w'))
print('Done')
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_18792\3609650840.py in <module>
----> 1 from openmm.app import *
2 from openmm import *
3 from openmm.unit import *
4
5
c:\Users\robot\anaconda3\envs\openmm\lib\site-packages\openmm\__init__.py in <module>
17 'lib': version.openmm_library_path, 'path': _path}
18
---> 19 from openmm.openmm import *
20 from openmm.vec3 import Vec3
21 from openmm.mtsintegrator import MTSIntegrator, MTSLangevinIntegrator
c:\Users\robot\anaconda3\envs\openmm\lib\site-packages\openmm\openmm.py in <module>
11 # Import the low-level C/C++ module
12 if __package__ or "." in __name__:
---> 13 from . import _openmm
14 else:
15 import _openmm
ImportError: DLL load failed: The specified procedure could not be found.
Changing the imports to simtk gives:
from simtk.openmm.app import *
from simtk.openmm import *
from simtk.unit import *
print('Loading...')
pdb = PDBFile('test1cpy_pdbfixed_moved.pdb')
forcefield = ForceField('amber99sb.xml', 'tip3p.xml')
modeller = Modeller(pdb.topology, pdb.positions)
print('Adding hydrogens...')
modeller.addHydrogens(forcefield)
print('Adding solvent...')
modeller.addSolvent(forcefield, padding=1*nanometer)
print('Minimizing...')
system = forcefield.createSystem(modeller.topology, nonbondedMethod=PME)
integrator = VerletIntegrator(0.001*picoseconds)
simulation = Simulation(modeller.topology, system, integrator)
simulation.context.setPositions(modeller.positions)
simulation.minimizeEnergy(maxIterations=100)
print('Saving...')
positions = simulation.context.getState(getPositions=True).getPositions()
PDBFile.writeFile(simulation.topology, positions, open('output_solvent.pdb', 'w'))
print('Done')
Loading...
Adding hydrogens...
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_18792\1924004758.py in <module>
9 modeller = Modeller(pdb.topology, pdb.positions)
10 print('Adding hydrogens...')
---> 11 modeller.addHydrogens(forcefield)
12 print('Adding solvent...')
13 modeller.addSolvent(forcefield, padding=1*nanometer)
c:\Users\robot\anaconda3\envs\openmm\lib\site-packages\simtk\openmm\app\modeller.py in addHydrogens(self, forcefield, pH, variants, platform)
c:\Users\robot\anaconda3\envs\openmm\lib\site-packages\simtk\openmm\app\modeller.py in loadHydrogenDefinitions(file)
c:\Users\robot\anaconda3\envs\openmm\lib\xml\etree\ElementTree.py in parse(source, parser)
1195 """
1196 tree = ElementTree()
-> 1197 tree.parse(source, parser)
1198 return tree
1199
c:\Users\robot\anaconda3\envs\openmm\lib\xml\etree\ElementTree.py in parse(self, source, parser)
585 close_source = False
586 if not hasattr(source, "read"):
--> 587 source = open(source, "rb")
588 close_source = True
589 try:
FileNotFoundError: [Errno 2] No such file or directory: 'c:\\Users\\robot\\anaconda3\\envs\\openmm\\lib\\site-packages\\simtk\\openmm\\app\\data\\hydrogens.xml'
Is it possible you're running this from a directory that contains a subdirectory called openmm
?
I am just running the above from the desktop as the working dir.
import os
print (os.getcwd())
c:\Users\robot\Desktop
And I assume you do not have a folder on your desktop called openmm
? I just want to make completely sure of it, since that will cause strange looking errors in your code.
Apologies, I misread your earlier reply. Correct, no folders or files even contain the word openmm in the working dir.
If I understand correctly, it works when running a script from the command line but fails when running inside a Jupyter notebook. Is that correct?
I really don't understand why that would happen, though clearly it must have something to do with how Jupyter is configuring the Python kernel.
Interesting! Actually, all of my examples above were in a notebook. But, after reading your message, I just tried them as scripts and now they function, thank you! Perhaps this will help @cartercanedy as well for now, though I too do not know why there is an issue with notebooks.
Hi! I get something similar running the pytests of a library with a CI.yaml workflow for "windows-latest" and Python 3.9. The tests fail when openmm is imported. This is the yaml file to create the conda env. Are we doing something wrong?
Run echo 'import pyunitwizard ; print(pyunitwizard.__version__)' | python
echo 'import pyunitwizard ; print(pyunitwizard.__version__)' | python
shell: C:\Program Files\Git\bin\bash.EXE -l {0}
env:
CONDA_PKGS_DIR: C:\Users\runneradmin\conda_pkgs_dir
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:\a\PyUnitWizard\PyUnitWizard\pyunitwizard\__init__.py", line 18, in <module>
from .main import unit, quantity, get_form, get_value, get_unit, is_quantity, is_unit
File "D:\a\PyUnitWizard\PyUnitWizard\pyunitwizard\main.py", line 4, in <module>
from ._private_tools.quantity_or_unit import ArrayLike, QuantityOrUnit, QuantityLike, UnitLike
File "D:\a\PyUnitWizard\PyUnitWizard\pyunitwizard\_private_tools\quantity_or_unit.py", line 5, in <module>
import openmm.unit as openmm_unit
File "C:\Miniconda\envs\test\lib\site-packages\openmm\__init__.py", line 19, in <module>
from openmm.openmm import *
File "C:\Miniconda\envs\test\lib\site-packages\openmm\openmm.py", line 13, in <module>
from . import _openmm
ImportError: DLL load failed while importing _openmm: The specified module could not be found.
Error: Process completed with exit code 1.
I ran into this as well in a fresh conda environment on Windows. Applying the changes in wrappers\python\openmm\__init__.py
from 4142e19827fd6c9c98b4369e9908c78926f59929 and 952d3402d12dda9931a0af2dce24fd9875e9b730 to lib\site-packages\openmm\__init.py__
in my conda env allowed OpenMM dlls to be successfully imported.
The addition of the lib directory to PATH doesn't seem to be effective anymore as of Python 3.8+. Process Monitor doesn't report any checking of Library\lib
but it was automatically checking Library\bin
.
Hi, everyone. I met the same issue yesterday. According to this, it might be a issue of Python > 3.8. So I successfully installed OpenMM like this:
conda create -c conda-forge --name openmm python=3.7 openmm
Now it works:
(openmm) C:\Users\Administrator>python -m openmm.testInstallation
OpenMM Version: 7.7
Git Revision: 130124a3f9277b054ec40927360a6ad20c8f5fa6
There are 4 Platforms available:
1 Reference - Successfully computed forces
2 CPU - Successfully computed forces
3 CUDA - Error computing forces with CUDA platform
4 OpenCL - Successfully computed forces
CUDA platform error: Error loading CUDA module: CUDA_ERROR_UNSUPPORTED_PTX_VERSION (222)
Median difference in forces between platforms:
Reference vs. CPU: 6.28915e-06
Reference vs. OpenCL: 6.72396e-06
CPU vs. OpenCL: 7.17402e-07
All differences are within tolerance.
Maybe the installing tutorial should be upgraded to help newbies like me.
See my comments in https://github.com/openmm/openmm/issues/3905#issuecomment-1382247201. The behavior depends on your Python version, whether your Python came from anaconda/miniconda or somewhere else, and what version of OpenMM you're using.