I need to build a Bayesian Network using naive bayes with libpgm.
The BN structure is known, so I just need to import it as a GraphSkeleton object with libpgm.graphskeleton.
When I run the code, it gives me the following error:
Traceback (most recent call last):
File "C:\Users\X\Documents\Modelli Probabilistici\0-NEW\reteBayesiana1.py", line 3, in <module>
from libpgm.graphskeleton import GraphSkeleton
File "C:\Users\X\AppData\Local\Programs\Python\Python37-32\lib\site-packages\libpgm\graphskeleton.py", line 29, in <module>
from dictionary import Dictionary
<b>ModuleNotFoundError: No module named 'dictionary'</b>
I installed the library using "pip3 install libpgm" and I didn't get any errors during the installation.
Here is my Code:
import libpgm
from libpgm.graphskeleton import GraphSkeleton
skel = GraphSkeleton()
skel.load("skeleton.txt")
...
I checked my libraries folder and libpgm seems to be installed correctly, also there are both a 'graphskeleton.py' file and a 'dictionary.py' file and they both seem to have the objects needed (GraphSkeleton and Dictionary, which is required for 'graphskeleton.py')
Related
I have installed Tensorflow and all its libraries following various websites and my terminal actually tells me they are installed and have been upgraded to their last versions, but somehow when I try to run the code in Python it keeps giving me the same error. In case you were wondering the Python code itself works fine on my laptop.
The error code says as it follows:
tensorflow/core/platform/hadoop/hadoop_file_system.cc:132] HadoopFileSystem load error: libhdfs.so: cannot open shared object file: No such file or directory
Traceback (most recent call last):
File "/media/pi/8F3B-E71C/TRachscope/livefeed_tensorflow_model.py", line 5, in <module>
from keras import models
File "/home/pi/.local/lib/python3.7/site-packages/keras/__init__.py", line 25, in <module>
from keras import models
File "/home/pi/.local/lib/python3.7/site-packages/keras/models.py", line 19, in <module>
from keras import backend
File "/home/pi/.local/lib/python3.7/site-packages/keras/backend.py", line 39, in <module>
from tensorflow.python.eager.context import get_config
ImportError: cannot import name 'get_config' from 'tensorflow.python.eager.context' (/home/pi/.local/lib/python3.7/site-packages/tensorflow_core/python/eager/context.py)**
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".
I am converting the T5 model from pytorch to ONNX using this script, but I am running into an Import module error. I don't think this a structural problem as this script has been used before by other people with no issues. Any ideas as to why I might be getting this error?
Here is the full error:
Traceback (most recent call last):
File "c:GitHub\models\text\machine_comprehension\t5\dependencies\T5-export.py", line 2, in <module>
from .models import CombinedDecoder, SimplifiedT5Encoder
ImportError: attempted relative import with no known parent package
I have uninstalled and re-installed the latest version of datatable from the repo
16:42:49/seirdc2.March8.in $sudo pip3 install 'datatable==0.10.1'
Successfully installed datatable-0.10.1
Let's see the version:
import datatable as dt
print(f'datatable version={dt.__version__}')
Um oops !
Traceback (most recent call last):
File "/git/corona/python/pointr/experiments/python/datatable.py", line 18, in <module>
import datatable as dt
File "/git/corona/python/pointr/experiments/python/datatable.py", line 19, in <module>
print(f'datatable version={dt.__version__}')
AttributeError: module 'datatable' has no attribute '__version__'
But why?
Note: I have seen other strangeness with this package: e.g. not finding Frame - though not consistently.
It appears that the problem has nothing to do with datatable. Look at the traceback:
Traceback (most recent call last):
File "/git/corona/python/pointr/experiments/python/datatable.py", line 18, in <module>
import datatable as dt
File "/git/corona/python/pointr/experiments/python/datatable.py", line 19, in <module>
print(f'datatable version={dt.__version__}')
AttributeError: module 'datatable' has no attribute '__version__'
Doesn't it strike you as suspicious that you have line 18 "calling" line 19? I mean, how could it be? Here's how:
When you name your script datatable.py and then do import datatable, then instead of importing the actual module from site-packages, it imports the "module" datatable.py instead. Basically, the file imports itself. And the way python manages imports, is that it creates a "stub" module in the sys.modules first (in order to prevent infinite recursions during imports). In your case, the module tries to import itself, so the stub module is fetched instead -- and then when you try to print its __version__ variable, turns out it doesn't exist.
You can verify this by printing dt.__file__ instead, which should show the location of the file that is being imported.
Needless to say, all this is not specific to datatable in any way; for example if you created a file numpy.py and then tried to import numpy, you'd run into same problems.
I am trying to add an external python library from a third party software into Spyder so I can work with it. I have already tried the following:
Adding library path containing .py files to Tools>PYTHONPATH manager
Synchronizing the path
Updating module names list through Tools>Update Module names list
However, when I try to import modules from this library I get two types of errors:
import easy
Traceback (most recent call last):
File "<ipython-input-2-685519d35f15>", line 1, in <module>
import easy
File "C:\Program Files (x86)\Plaxis\PLAXIS 2D\plxscripting\easy.py", line 24, in <module>
from .server import Server, InputProcessor
ValueError: Attempted relative import in non-package
The second type of error as follows:
from plxscripting.easy import *
Traceback (most recent call last):
File "<ipython-input-1-a40c101d3bb0>", line 1, in <module>
from plxscripting.easy import *
ImportError: No module named plxscripting.easy
I don't understand why Spyder is not recognizing these libraries. The path has been added and shows up on the manager. What constitutes a python module? Is it not just the .py file with module name prefix? Is not the path sufficient to work with the library through the IDE?