ModuleNotFoundError: No module named '_nlopt' - python

I'm having trouble importing the nlopt library in Python 3.7.4.
I'm using anaconda, but as nlopt isn't available through conda install, I've installed nlopt with pip.
Here is the error message:
>>> import nlopt
Traceback (most recent call last):
File "C:\Users\nick.rhodes\AppData\Local\Continuum\anaconda3\lib\site-packages\nlopt\nlopt.py", line 22, in swig_import_helper
return importlib.import_module(mname)
File "C:\Users\nick.rhodes\AppData\Local\Continuum\anaconda3\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 670, in _load_unlocked
File "<frozen importlib._bootstrap>", line 583, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 1043, in create_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: DLL load failed: The specified module could not be found.
During handling of the above exception, another exception occurred:
File "<stdin>", line 1, in <module>
File "C:\Users\nick.rhodes\AppData\Local\Continuum\anaconda3\lib\site-packages\nlopt\__init__.py", line 1, in <module>
from .nlopt import *
File "C:\Users\nick.rhodes\AppData\Local\Continuum\anaconda3\lib\site-packages\nlopt\nlopt.py", line 25, in <module>
_nlopt = swig_import_helper()
File "C:\Users\nick.rhodes\AppData\Local\Continuum\anaconda3\lib\site-packages\nlopt\nlopt.py", line 24, in swig_import_helper
return importlib.import_module('_nlopt')
File "C:\Users\nick.rhodes\AppData\Local\Continuum\anaconda3\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named '_nlopt'

Since you are using conda, You should install nlopt using conda
conda install -c conda-forge nlopt

Related

#quickfix import failed in windows10

system: windows 10,
language: python 3.6.5
I installed the quickfix 1.15.1 by pip install quickfix-1.15.1-cp36-cp36m-win_amd64.whl downloaded from web.
When I try like:
import quickfix
errors:
*Connected to pydev debugger (build 202.6948.78)
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\quickfix.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "C:\ProgramData\Anaconda3\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 658, in _load_unlocked
File "<frozen importlib._bootstrap>", line 571, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 922, in create_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: DLL load failed: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\ProgramData\Anaconda3\lib\site-packages\quickfix.py", line 21, in <module>
_quickfix = swig_import_helper()
File "C:\ProgramData\Anaconda3\lib\site-packages\quickfix.py", line 20, in swig_import_helper
return importlib.import_module('_quickfix')
File "C:\ProgramData\Anaconda3\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: DLL load failed: The specified module could not be found.
Process finished with exit code 1*
And I had installed .Net 5.0
If you are sure that quickfix is correctly installed in your environment and the PYTHONPATH has access to this environment, then you can try to check the option 'Load conda env vars before run?' on Window -> Preferences -> PyDev -> Interpreters -> Python Interpreter.
It's possible that the import is failing because that package is using an environment variable to load the modules, and PyDev by default is not loading this variable before running the script.

Cannot be imported 'nlopt' python's package

Installed nlopt: pip install nlopt on Windows 10.
Python: Python 3.7.1 (default, Dec 10 2018, 22:54:23) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32.
command import nlopt fails with message
>>> import nlopt
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Continuum\anaconda3\lib\site-packages\nlopt\nlopt.py", line 22, in swig_import_helper
return importlib.import_module(mname)
File "C:\Users\user\AppData\Local\Continuum\anaconda3\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 670, in _load_unlocked
File "<frozen importlib._bootstrap>", line 583, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 1043, in create_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: DLL load failed: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\user\AppData\Local\Continuum\anaconda3\lib\site-packages\nlopt\__init__.py", line 1, in <module>
from .nlopt import *
File "C:\Users\user\AppData\Local\Continuum\anaconda3\lib\site-packages\nlopt\nlopt.py", line 25, in <module>
_nlopt = swig_import_helper()
File "C:\Users\user\AppData\Local\Continuum\anaconda3\lib\site-packages\nlopt\nlopt.py", line 24, in swig_import_helper
return importlib.import_module('_nlopt')
File "C:\Users\user\AppData\Local\Continuum\anaconda3\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named '_nlopt'
when added 2 commands
>>> import sys
>>> sys.path.append(r'C:\Users\user\AppData\Local\Continuum\anaconda3\lib\site-packages\nlopt')
fails with other message:
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Continuum\anaconda3\lib\site-packages\nlopt\nlopt.py", line 22, in swig_import_helper
return importlib.import_module(mname)
File "C:\Users\user\AppData\Local\Continuum\anaconda3\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 670, in _load_unlocked
File "<frozen importlib._bootstrap>", line 583, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 1043, in create_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: DLL load failed: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\user\AppData\Local\Continuum\anaconda3\lib\site-packages\nlopt\__init__.py", line 1, in <module>
from .nlopt import *
File "C:\Users\user\AppData\Local\Continuum\anaconda3\lib\site-packages\nlopt\nlopt.py", line 25, in <module>
_nlopt = swig_import_helper()
File "C:\Users\user\AppData\Local\Continuum\anaconda3\lib\site-packages\nlopt\nlopt.py", line 24, in swig_import_helper
return importlib.import_module('_nlopt')
File "C:\Users\user\AppData\Local\Continuum\anaconda3\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: DLL load failed: The specified module could not be found.

Failed to import Tensorflow in Anaconda

I've installed CPU version of Tensorflow on the Anaconda3-5.2.0-Windows-x64 on the Windows 10 with the following sequence of commands:
conda create -n tensorflow pip python=3.6
activate tensorflow
pip install --ignore-installed --upgrade tensorflow
and no errors occured. But then I've tried to import Tensorflow and the following text appeared
Python 3.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 13:32:41) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
Traceback (most recent call last):
File "C:\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 14, in swig_import_helper
return importlib.import_module(mname)
File "C:\Anaconda3\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 658, in _load_unlocked
File "<frozen importlib._bootstrap>", line 571, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 922, in create_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: DLL load failed:
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 17, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 16, in swig_import_helper
return importlib.import_module('_pywrap_tensorflow_internal')
File "C:\Anaconda3\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Anaconda3\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "C:\Anaconda3\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 14, in swig_import_helper
return importlib.import_module(mname)
File "C:\Anaconda3\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 658, in _load_unlocked
File "<frozen importlib._bootstrap>", line 571, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 922, in create_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: DLL load failed:
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 17, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 16, in swig_import_helper
return importlib.import_module('_pywrap_tensorflow_internal')
File "C:\Anaconda3\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'
Failed to load the native TensorFlow runtime.
I've checked out some similar questions here and I have installed Microsoft Visual C++ 2015 Redistributable.
Use conda install tensorflow instead of pip
For installations within anaconda virtual environments its preferable to use conda install package_name
or switch back to version <1.6 i.e pip install tensorflow==1.5
Solution reference : GitHub-TensorFlow

Error importing tensorflow module

When I use the command import tensorflow as tf I get the following error:
Traceback (most recent call last):
File "C:\Users\rodri647\AppData\Local\Continuum\anaconda2\envs\chemvae\lib\sit
e-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 14, in swig_im
port_helper
return importlib.import_module(mname)
File "C:\Users\rodri647\AppData\Local\Continuum\anaconda2\envs\chemvae\lib\imp
ortlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 658, in _load_unlocked
File "<frozen importlib._bootstrap>", line 571, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 922, in create_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: DLL load failed with error code -1073741795
...
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\rodri647\AppData\Local\Continuum\anaconda2\envs\chemvae\lib\sit
e-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\rodri647\AppData\Local\Continuum\anaconda2\envs\chemvae\lib\sit
e-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 17, in <module
>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\rodri647\AppData\Local\Continuum\anaconda2\envs\chemvae\lib\sit
e-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 16, in swig_im
port_helper
return importlib.import_module('_pywrap_tensorflow_internal')
File "C:\Users\rodri647\AppData\Local\Continuum\anaconda2\envs\chemvae\lib\imp
ortlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/install_sources#common_installation_probl
ems
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
>>>
I'm using tensorflow gpu 1.1.0 on python 3.5. The code I'm trying to compile is here: https://github.com/aspuru-guzik-group/chemical_vae
Seems like you have no installed MSVCP140.DLL in your system. You can try installing Visual C++ Redistributable, uninstall then install TF again.
If it doesn't work, try to download and import this dll directly as it explained here.

Tensorflow GPU 1.2 installation stacktrace for CUDA v8.0

I am trying to install tensorflow-gpu version on my windows 10. I have installed CUDA v8 and cuDNN 6. Following this I tried to install tensorflow-gpu with the help of pip installer. But when I try to import tensoflow, I get the following stacktrace error on my console
>>>import tensorflow
Traceback (most recent call last):
File "C:\Users\gokku\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "C:\Users\gokku\AppData\Local\Programs\Python\Python35\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
File "<frozen importlib._bootstrap>", line 577, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 906, in create_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
ImportError: DLL load failed: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\gokku\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\gokku\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\gokku\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
return importlib.import_module('_pywrap_tensorflow_internal')
File "C:\Users\gokku\AppData\Local\Programs\Python\Python35\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: No module named '_pywrap_tensorflow_internal'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\gokku\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import *
File "C:\Users\gokku\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\gokku\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 52, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\gokku\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "C:\Users\gokku\AppData\Local\Programs\Python\Python35\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
File "<frozen importlib._bootstrap>", line 577, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 906, in create_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
ImportError: DLL load failed: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\gokku\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\gokku\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\gokku\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
return importlib.import_module('_pywrap_tensorflow_internal')
File "C:\Users\gokku\AppData\Local\Programs\Python\Python35\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: No module named '_pywrap_tensorflow_internal'
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/install_sources#common_installation_problems
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
Can anyone help with this problem?
Moving my comment to an answer:
From the documentation see this question:
On Windows, running "import tensorflow" generates No module named "_pywrap_tensorflow" error

Categories

Resources