ImportError: DLL load failed: The specified module could not be found.

Answered

I'm a new Python and PyCharm user, so apologies if this has been answered before. I did check the knowledge base. Here is the traceback.

C:\Users\lawrence.berry\Anaconda3\python.exe "C:/Users/lawrence.berry/OneDrive - TSGateway/Python/Options_Screener/Import_and_Wrangle.py"
Traceback (most recent call last):
File "C:/Users/lawrence.berry/OneDrive - TSGateway/Python/Options_Screener/Import_and_Wrangle.py", line 2, in <module>
import quantsbin.derivativepricing as qb
File "C:\Users\lawrence.berry\Anaconda3\lib\site-packages\quantsbin\derivativepricing\__init__.py", line 6, in <module>
from .instruments import EqOption, FutOption, FXOption, ComOption
File "C:\Users\lawrence.berry\Anaconda3\lib\site-packages\quantsbin\derivativepricing\instruments.py", line 9, in <module>
from .engineconfig import PricingEngine
File "C:\Users\lawrence.berry\Anaconda3\lib\site-packages\quantsbin\derivativepricing\engineconfig.py", line 6, in <module>
from .namesnmapper import MODEL_MAPPER, IV_MODELS, ANALYTICAL_GREEKS, OBJECT_MODEL
File "C:\Users\lawrence.berry\Anaconda3\lib\site-packages\quantsbin\derivativepricing\namesnmapper.py", line 111, in <module>
from . import pricingmodels as pm
File "C:\Users\lawrence.berry\Anaconda3\lib\site-packages\quantsbin\derivativepricing\pricingmodels.py", line 12, in <module>
from scipy import optimize
File "C:\Users\lawrence.berry\Anaconda3\lib\site-packages\scipy\optimize\__init__.py", line 398, in <module>
from ._nnls import nnls
ImportError: DLL load failed: The specified module could not be found

 

My Python script has been running without this problem for a couple of weeks now, but suddenly today it stopped working. The only thing I added to my script immediately before it stopped working was to add a new library. After "pip install tabulate", I added the following to the script

from tabulate import tabulate

 

Any help would be very much appreciated. 

9 comments
Comment actions Permalink

Hi,

If you run this command in the command line C:\Users\lawrence.berry\Anaconda3\python.exe "C:/Users/lawrence.berry/OneDrive - TSGateway/Python/Options_Screener/Import_and_Wrangle.py", does it work?

0
Comment actions Permalink

Thanks for your response Sergey. Here is a copy of what happened in the Terminal when I entered the cmd. Doesn't look as though it has worked.

(base) C:\Users\lawrence.berry\OneDrive - TSGateway\Python\Volatility-Trading-Analysis-with-Python>C:\Users\lawrence.berry\Anaconda3\python.exe "C:/Users/lawrence.berry/OneDrive - TSGateway/Python/Options_Screener/Import_and_Wrangle.py
"
Traceback (most recent call last):
File "C:/Users/lawrence.berry/OneDrive - TSGateway/Python/Options_Screener/Import_and_Wrangle.py", line 2, in <module>
import quantsbin.derivativepricing as qb
File "C:\Users\lawrence.berry\Anaconda3\lib\site-packages\quantsbin\derivativepricing\__init__.py", line 6, in <module>
from .instruments import EqOption, FutOption, FXOption, ComOption
File "C:\Users\lawrence.berry\Anaconda3\lib\site-packages\quantsbin\derivativepricing\instruments.py", line 9, in <module>
from .engineconfig import PricingEngine
File "C:\Users\lawrence.berry\Anaconda3\lib\site-packages\quantsbin\derivativepricing\engineconfig.py", line 6, in <module>
from .namesnmapper import MODEL_MAPPER, IV_MODELS, ANALYTICAL_GREEKS, OBJECT_MODEL
File "C:\Users\lawrence.berry\Anaconda3\lib\site-packages\quantsbin\derivativepricing\namesnmapper.py", line 111, in <module>
from . import pricingmodels as pm
File "C:\Users\lawrence.berry\Anaconda3\lib\site-packages\quantsbin\derivativepricing\pricingmodels.py", line 12, in <module>
from scipy import optimize
File "C:\Users\lawrence.berry\Anaconda3\lib\site-packages\scipy\optimize\__init__.py", line 398, in <module>
from ._nnls import nnls
ImportError: DLL load failed: The specified module could not be found.

0
Comment actions Permalink

Since you get the same error in the CMD, it means that the problem is not related to PyCharm. I'd recommend asking on Python and conda related forums and searching for similar issues.

0
Comment actions Permalink

Thanks - will do

0
Comment actions Permalink

I'm getting this same error but with SQLite3.

I'm able to execute the import SQLite3 command from within a Jupyter notebook.

0
Comment actions Permalink
import sqlite3

print("Hello World")

above is my script, below is the error message

"C:\Users\Fname Lname\Documents\GitHub\Code Snippets\Kattis\untitled\venv\Scripts\python.exe" "C:/Users/Fname Lname/Documents/GitHub/Code Snippets/Kattis/untitled/testimport.py"

Traceback (most recent call last):
File "C:/Users/Fname Lname/Documents/GitHub/Code Snippets/Kattis/untitled/testimport.py", line 1, in <module>
import sqlite3
File "C:\Users\Fname Lname\Anaconda3\lib\sqlite3\__init__.py", line 23, in <module>
from sqlite3.dbapi2 import *
File "C:\Users\Fname Lname\Anaconda3\lib\sqlite3\dbapi2.py", line 27, in <module>
from _sqlite3 import *
ImportError: DLL load failed: The specified module could not be found.

Process finished with exit code 1

0
Comment actions Permalink

Hello, 

 

Please run : 

C:\Users\Fname Lname\Documents\GitHub\Code Snippets\Kattis\untitled\venv\Scripts\python.exe "C:/Users/Fname Lname/Documents/GitHub/Code Snippets/Kattis/untitled/testimport.py"

 

in the command line, will you get the same result? 

0
Comment actions Permalink

Hlo I recently started using pycharm and python and found this error:

I request you to help me out with this:


(venv) C:\Users\PUJITHA REDDY\PycharmProjects\HobbyProject\cakechat>python tools/fetch.py
Using TensorFlow backend.
2021-07-03 22:13:28.484202: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compile
d to use: AVX2
Traceback (most recent call last):
File "tools/fetch.py", line 15, in <module>
from cakechat.dialog_model.factory import get_trained_model
File "C:\Users\PUJITHA REDDY\PycharmProjects\HobbyProject\cakechat\cakechat\dialog_model\factory.py", line 8, in <module>
from cakechat.dialog_model.inference_model import InferenceCakeChatModel
File "C:\Users\PUJITHA REDDY\PycharmProjects\HobbyProject\cakechat\cakechat\dialog_model\inference_model.py", line 1, in <module>
from cakechat.dialog_model.keras_model import KerasTFModelIsolator
File "C:\Users\PUJITHA REDDY\PycharmProjects\HobbyProject\cakechat\cakechat\dialog_model\keras_model.py", line 11, in <module>
from cakechat.dialog_model.abstract_model import AbstractModel
File "C:\Users\PUJITHA REDDY\PycharmProjects\HobbyProject\cakechat\cakechat\dialog_model\abstract_model.py", line 6, in <module>
from cakechat.dialog_model.quality.metrics.utils import MetricsSerializer
File "C:\Users\PUJITHA REDDY\PycharmProjects\HobbyProject\cakechat\cakechat\dialog_model\quality\__init__.py", line 2, in <module>
from cakechat.dialog_model.quality.metrics.lexical_simlarity import calculate_lexical_similarity, get_tfidf_vectorizer
File "C:\Users\PUJITHA REDDY\PycharmProjects\HobbyProject\cakechat\cakechat\dialog_model\quality\metrics\lexical_simlarity.py", line 3, in <module>
from sklearn.feature_extraction.text import TfidfVectorizer
File "C:\Users\PUJITHA REDDY\PycharmProjects\HobbyProject\cakechat\venv\lib\site-packages\sklearn\__init__.py", line 64, in <module>
from .base import clone
File "C:\Users\PUJITHA REDDY\PycharmProjects\HobbyProject\cakechat\venv\lib\site-packages\sklearn\base.py", line 13, in <module>
from .utils.fixes import signature
File "C:\Users\PUJITHA REDDY\PycharmProjects\HobbyProject\cakechat\venv\lib\site-packages\sklearn\utils\__init__.py", line 16, in <module>
from .fixes import _Sequence as Sequence
File "C:\Users\PUJITHA REDDY\PycharmProjects\HobbyProject\cakechat\venv\lib\site-packages\sklearn\utils\fixes.py", line 92, in <module>
from scipy.sparse.linalg import lsqr as sparse_lsqr # noqa
File "C:\Users\PUJITHA REDDY\PycharmProjects\HobbyProject\cakechat\venv\lib\site-packages\scipy\sparse\linalg\__init__.py", line 114, in <module>
from .isolve import *
File "C:\Users\PUJITHA REDDY\PycharmProjects\HobbyProject\cakechat\venv\lib\site-packages\scipy\sparse\linalg\isolve\__init__.py", line 6, in <module>
from .iterative import *
File "C:\Users\PUJITHA REDDY\PycharmProjects\HobbyProject\cakechat\venv\lib\site-packages\scipy\sparse\linalg\isolve\iterative.py", line 10, in <module>
from . import _iterative
ImportError: DLL load failed: The specified module could not be found.

0
Comment actions Permalink

Kpujithareddy144 To check if the issue is IDE-related, could you please make sure the code runs correctly from the terminal outside of IDE?

One way to do that is to copy the first line of the console output from PyCharm to the terminal.

For more information on how to run code from the terminal, please see:
https://docs.python.org/3/using/cmdline.html#command-line

If you're using virtualenv interpreter in PyCharm, you may need to activate it in the command line as well:
https://virtualenv.pypa.io/en/latest/user_guide.html#activators

0

Please sign in to leave a comment.