Theano Import Error, python 3.6 windows 10 - python-3.x

I'm trying to import theano and I'm getting an import error.
I've seen common issues with theano relate to not having g++, mingw, or libpython installed. I can confirm I have all three installed. g++ 4.7.0, mingw 4.7, libpython 2.1, and theano 1.0.1.
Any suggestions on what to chase down next? I'm a little stumped.
When I run a simple python (3.6) file trying to import theano I get the following:
You can find the C code in this temporary file: C:\Users\CAVEJO~1\AppData\Local\Temp\theano_compilation_error_1b3hfusl
Traceback (most recent call last):
File "C:\Users\Cave Johnson\AppData\Local\Programs\Python\Python36-32\lib\site-packages\theano\gof\lazylinker_c.py", line 75, in <module>
raise ImportError()
ImportError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Cave Johnson\AppData\Local\Programs\Python\Python36-32\lib\site-packages\theano\gof\lazylinker_c.py", line 92, in <module>
raise ImportError()
ImportError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Cave Johnson\AppData\Local\Programs\Python\Python36-32\Projects\Pandas\housing_prices.py", line 4, in <module>
import theano
File "C:\Users\Cave Johnson\AppData\Local\Programs\Python\Python36-32\lib\site-packages\theano\__init__.py", line 110, in <module>
from theano.compile import (
File "C:\Users\Cave Johnson\AppData\Local\Programs\Python\Python36-32\lib\site-packages\theano\compile\__init__.py", line 12, in <module>
from theano.compile.mode import *
File "C:\Users\Cave Johnson\AppData\Local\Programs\Python\Python36-32\lib\site-packages\theano\compile\mode.py", line 11, in <module>
import theano.gof.vm
File "C:\Users\Cave Johnson\AppData\Local\Programs\Python\Python36-32\lib\site-packages\theano\gof\vm.py", line 673, in <module>
from . import lazylinker_c
File "C:\Users\Cave Johnson\AppData\Local\Programs\Python\Python36-32\lib\site-packages\theano\gof\lazylinker_c.py", line 127, in <module>
preargs=args)
File "C:\Users\Cave Johnson\AppData\Local\Programs\Python\Python36-32\lib\site-packages\theano\gof\cmodule.py", line 2359, in compile_str
(status, compile_stderr.replace('\n', '. ')))
Exception: Compilation failed (return status=1): The system cannot find the path specified.
.

I had the same issue, and it came down to missing dependencies.
This seemed to be the key for me:
conda install numpy scipy mkl-service libpython m2w64-toolchain
conda install -c conda-forge blas
See https://github.com/Theano/Theano/issues/6532 or more details.

Related

'Invalid syntax' error when importing torch (Linux)

I'm trying to install torch under miniconda and simple import torch gives me the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/vol/tcm17/username/miniconda3/lib/python3.8/site-packages/torch/__init__.py", line 779, in <module>
from .serialization import save, load
File "/vol/tcm17/username/miniconda3/lib/python3.8/site-packages/torch/serialization.py", line 18, in <module>
from typing_extensions import TypeAlias
File "/home/username/.local/lib/python3.8/site-packages/typing_extensions.py", line 880
if stripped_args
Interestingly, if I repeat import torch again the error message changes:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/vol/tcm17/username/miniconda3/lib/python3.8/site-packages/torch/__init__.py", line 249, in <module>
for name in dir(_C):
NameError: name '_C' is not defined
I'm not using notebooks, python version is 3.8.16, pytorch version is 1.13.1. Miniconda is installed in a local folder (it's a university server so I can only do it like this due to disk space restrictions), the server runs on Ubuntu.
What could possibly be the problem?
The only recommendation I found for similar problems is to install Cython but it didn't help.
Downgraded to python 3.6 and this somehow solved the problem.

ImportError DLL load failed while importing fasttext_corpusfile

When I try to import gensim, I get the below error:
Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\gensim\models\fasttext.py", line 264, in <module>
from gensim.models.fasttext_corpusfile import train_epoch_sg, train_epoch_cbow
ImportError: DLL load failed while importing fasttext_corpusfile: 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\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\gensim\__init__.py", line 11, in <module>
from gensim import parsing, corpora, matutils, interfaces, models, similarities, utils # noqa:F401
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\gensim\models\__init__.py", line 22, in <module>
from .fasttext import FastText # noqa:F401
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\gensim\models\fasttext.py", line 266, in <module>
raise utils.NO_CYTHON
RuntimeError: Compiled extensions are unavailable. If you've installed from a package, ask the package maintainer to include compiled extensions. If you're building Gensim from source yourself, install Cython and a C compiler, and then run `python setup.py build_ext --inplace` to retry.
My computer is Windows Server 2022 Data Center, python is 3.8.10, gensim is 4.2.0.
How can I solve this problem? Thank you for your help.
I re-installed gensim (gensim-4.2.0-cp39-cp39-win_amd64.whl) from https://pypi.org/project/gensim/#files, but still had the above problem.

Why does a DLL error appear when importing tensorflow?

I recently got a new 64-bit windows 10 and installed pycharm. The pycharm I am using is Python 3.8.
When I installed tensorflow by running the command line, it worked fine. However, when I imported on my pycharm file (i.e. import tensorflow as tf), it produced an error as such:
Traceback (most recent call last):
File "C:\Users\leode\anaconda3\envs\Science Fair\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module>
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed while importing _pywrap_tensorflow_internal: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/leode/PycharmProjects/Science Fair/project.py", line 1, in <module>
import tensorflow as tf
File "C:\Users\leode\anaconda3\envs\Science Fair\lib\site-packages\tensorflow\__init__.py", line 41, in <module>
from tensorflow.python.tools import module_util as _module_util
File "C:\Users\leode\anaconda3\envs\Science Fair\lib\site-packages\tensorflow\python\__init__.py", line 40, in <module>
from tensorflow.python.eager import context
File "C:\Users\leode\anaconda3\envs\Science Fair\lib\site-packages\tensorflow\python\eager\context.py", line 35, in <module>
from tensorflow.python import pywrap_tfe
File "C:\Users\leode\anaconda3\envs\Science Fair\lib\site-packages\tensorflow\python\pywrap_tfe.py", line 28, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\leode\anaconda3\envs\Science Fair\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 83, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\leode\anaconda3\envs\Science Fair\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module>
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed while importing _pywrap_tensorflow_internal: The specified module could not be found.
Failed to load the native TensorFlow runtime.
However when I import tensorboard_plugin_wit:
import tensorboard_plugin_wit
It works fine.
What went wrong? If any of you need any further clarification, please comment- I'm not much of an expert on handling computers so I will do my best to answer:)
I figured out what the problem was. Unlike many third-party modules in python, installing tensorflow requires more than simply pip install . The way I installed tensorflow was by creating and activating a conda environment. For more information on how to install tensorflow via Pycharm, here is a helpful Youtube video: https://www.youtube.com/watch?v=5Ym-dOS9ssA&t=327s

Failed to import tensorflow

File "C:\Users\deepz\anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module>
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed while importing _pywrap_tensorflow_internal: 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\deepz\anaconda3\lib\site-packages\tensorflow\__init__.py", line 41, in <module>
from tensorflow.python.tools import module_util as _module_util
File "C:\Users\deepz\anaconda3\lib\site-packages\tensorflow\python\__init__.py", line 40, in <module>
from tensorflow.python.eager import context
File "C:\Users\deepz\anaconda3\lib\site-packages\tensorflow\python\eager\context.py", line 35, in <module>
from tensorflow.python import pywrap_tfe
File "C:\Users\deepz\anaconda3\lib\site-packages\tensorflow\python\pywrap_tfe.py", line 28, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\deepz\anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 83, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\deepz\anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module>
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed while importing _pywrap_tensorflow_internal: The specified module could not be found.
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/errors
on importing TensorFlow as tf
I am getting this error please can someone help me to solve this problem.
system HP 245 G5 and operating system windows 10 2004 version
If you have Anaconda installed I recommend you use Conda to install tensorflow into a new environment. Reason is Conda installs tensorflow and the required Cuda Toolkit and the proper version of cuDNN. Pip does not install these and you have to download them seperately, unzip and store them in directories. You also have to adjust you environment variable to point to these directories.

Installing Tensorflow on win10 ( installed but showing error while doing import tensorflow as tf)

I am using Windows 10Pro ss of my OS info
Using the latest version of Anaconda, python(version 3.8.3), TensorFlow version information as follows
Name: tensorflow
Version: 2.3.0
I installed Tensorflow CPU.
While importing TensorFlow I have the following errors.
Traceback (most recent call last):
File "C:\Users\Prakash\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed while importing _pywrap_tensorflow_internal: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\Prakash\Anaconda3\lib\site-packages\tensorflow_init_.py", line 41, in
from tensorflow.python.tools import module_util as module_util
File "C:\Users\Prakash\Anaconda3\lib\site-packages\tensorflow\python_init.py", line 40, in
from tensorflow.python.eager import context
File "C:\Users\Prakash\Anaconda3\lib\site-packages\tensorflow\python\eager\context.py", line 35, in
from tensorflow.python import pywrap_tfe
File "C:\Users\Prakash\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tfe.py", line 28, in
from tensorflow.python import pywrap_tensorflow
File "C:\Users\Prakash\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 83, in
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\Prakash\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed while importing _pywrap_tensorflow_internal: The specified module could not be found.
Failed to load the native TensorFlow runtime.
Screen shot of the error showning
please help me resolve this issue.
comment if any other information is needed

Resources