Python missing modules with Theano - python

i have installed theano a deep neural network library and am trying to run some examples, but it looks like the script cant find some of the modules. i tried setting path
export PYTHONPATH=/Library/Python/2.7/site-packages/theano
sys.path.append('/Library/Python/2.7/site-packages/theano')
but both are not working. I get this error. I see that the modules are properly installed in subdirectory of theano /Library/Python/2.7/site-packages/theano/tensor/.. but somehow python cant seem to find the modules
Please can someone help. I am using a mac.
$python theano_mnist.py
Traceback (most recent call last):
File "theano_mnist.py", line 45, in <module>
import theano
File "/Users/prabhubalakrishnan/Desktop/theano.py", line 6, in <module>
from theano.tensor.nnet import conv
ImportError: No module named tensor.nnet

There is an issue on Theano repository. As fast solution I have:
Opened the file "miniconda3/envs/YOUR_CONDA_ENV_NAME/lib/python3.4/site-packages/theano/tensor/signal/downsample.py"
change the import import pool in from . import pool
and it works!

Related

trouble importing autograd in python script

I'm trying to import autograd with the following line of code:
import autograd.numpy as np
However, I'm getting the following error when trying to run the script:
Traceback (most recent call last):
File "autograd.py", line 1, in <module>
import autograd.numpy as np
File "/home/hakon/Documents/FYS_STK4155/project2/code and plots/test/autograd.py", line 1, in <module>
import autograd.numpy as np
ModuleNotFoundError: No module named 'autograd.numpy'; 'autograd' is not a package
I've tried installing autograd through pip, pip3 and conda, but the error remains the same.
The problem is that your module (the one that you're running) has the same name that you're trying to import: autograd (.py). Try renaming your file and running it again.
aaossa's answer worked for me. If changing the module name that you are running doesn't work, please check if there is any other autograd(.py) that you created existing in your current directory. If so, you also need to change that file's name or delete it so that you can import "autograd".

No module named 'keras.backend.tensorflow_backend'

I am trying to learn from a python script on semantic search that uses sentence transformer-BERT, While compiling this python script (semantic_search.py) file I encountered the following error:
Traceback (most recent call last):
File "semantic_search.py", line 6, in <module>
import keras.backend.tensorflow_backend as tb
ModuleNotFoundError: No module named 'keras'
Kindly suggest possible source of error and corrections.
This is a problem with versions of keras and tensorflow. It sounds like this tutorial was written before keras became a part of tensorflow. For more info on why this happened and what version you should use, see this article.
Probably what you'd need is to change any imports in the script that start with keras to tensorflow.keras, if you have tensorflow version 2.0 and above. So for that line specifically, you probably want:
import tensorflow.keras.backend as tb

How to install or make working keras_retinanet.utils.gpu module?

I am trying to train M-RCNN using Keras and RetinaNet as in the Keras founder's example. I installed retinanet package but this module isn't found. May be it is related to that my TF doesn't use GPU? How to check that?
from keras_retinanet.utils.gpu import setup_gpu
Traceback (most recent call last):
File "<ipython-input-2-1f3ae263a7c6>", line 1, in <module>
from keras_retinanet.utils.gpu import setup_gpu
ModuleNotFoundError: No module named 'keras_retinanet.utils.gpu'
You probably need to install some submodules. The beginning of this code may help you https://www.kaggle.com/labintsevai/keras-retinanet-submission

Errors importing pyodbc

My background is Java/C++ and I'm very new to python. I'm trying to import pyodbc to my project which works alright if I do it via command line.
import odbc
However, when I try to do the same in pydev/eclipse, i get the following error which I cannot find a solution to. I suspect this may have something to do with Eclipse setup
Traceback (most recent call last):
File "C:\Users\a\workspace\TestPyProject\src\helloworld.py", line 2, in <module>
import pyodbc
File "C:\Users\a\AppData\Local\Continuum\Anaconda3\Lib\site-packages\sqlalchemy\dialects\mssql\pyodbc.py", line 105, in <module>
from .base import MSExecutionContext, MSDialect, VARBINARY
ImportError: attempted relative import with no known parent package
I'm really stuck here and any hints will be appreciated!
An incorrect library was imported into the External Libraries list of the project. After fixing it, the import is working.

Cannot import gi from PyGi in Spyder

I primarily use python for scientific computing and have become quite accustomed to Spyder. I am working on a mutlimedia project and would like to use the Gstreamer bindings for python. The best way I could find to install Gstreamer on Windows was through PyGi.
Now the problem, import gi works fine in both python and Ipython loaded in a command prompt. However, trying to do the same in Spyder results in:
Traceback (most recent call last):
File "<ipython-input-1-a23efdcdbcd8>", line 1, in <module>
import gi
File "C:\Users\Conner\Anaconda\Lib\site-packages\gi\__init__.py", line 42, in <module>
from . import _gi
ImportError: DLL load failed: The specified module could not be found.
I made sure the interpreter was the same and added C:\Users\Conner\Anaconda\Lib\site-packages to the PYTHONPATH to no avail.
I could develop it outside of Spyder but I am damn stubborn and I don't like when things don't work.

Categories