Folder being mistaken for module Error: no module named "GAN" - python

I'm running this github project: https://github.com/Biomatter-Designs/ProteinGAN
the second step says 2. Run the training script with python train_gan. but when I run the file I get:
/usr/local/bin/python3 /Users/user/Desktop/ProteinGAN-master/src/gan/train_gan.py
Traceback (most recent call last):
File "/Users/user/Desktop/ProteinGAN-master/src/gan/train_gan.py", line 8, in <module>
from gan.models import get_model, get_specific_hooks
ModuleNotFoundError: No module named 'gan'
I don't understand why it thinks the GAN folder is a module.

Had the issue error trying to import gan files on google colab.
I corrected my /content/gdrive folder to the exact path and it worked.
I hope this helps out.

Related

Python module not found when using MSIPred

I am very new to python. I am trying to use a pre-existing algorithm on my data:
https://github.com/wangc29/MSIpred
I downloaded the code from GitHub and used my command line installer as suggested on the first instruction of the vignette in the above link.
I save a python file in the same directory as the downloaded code and attempt to execute the first line:
import MSIpred as mp
I receive this error:
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
import MSIpred as mp
ImportError: No module named MSIpred
This is my directory organization. I have tried with both MSI_Smoker and MSI_Smoker2 as seen in the image below.
Any suggestions?
Edit:
In response to some comment, I tried moving the python script into the parent folder but I get the same error.
The easiest way is to add the lib path to the environment parameter PYTHONPATH(https://www.tutorialspoint.com/What-is-PYTHONPATH-environment-variable-in-Python)
export PYTHONPATH=$PYTHONPATH:`pwd` (replace `pwd` to the lib path)
link Python error "ImportError: No module named"

ModuleNotFound error even pip is already used

I am a new at Python and I have a roblem with installing one framework.
https://github.com/zalando/connexion
I have already used the command in the terminal 'pip install connexion'
But still when I try to start a programm I get such error:
PS C:\Users\fele\OneDrive\Desktop\Python\Uebergabe\pYTHON_BACKEND_2020_03_12> & "C:/Program Files (x86)/Python37-32/python.exe" "c:/Users/fele/OneDrive/Desktop/Python/Uebergabe/pYTHON_BACKEND_2020_03_12/test_local/test_local_application_hook.py"
Traceback (most recent call last):
File "c:/Users/fele/OneDrive/Desktop/Python/Uebergabe/pYTHON_BACKEND_2020_03_12/test_local/test_local_application_hook.py", line 9, in <module>
from cwsm import connexion_manager
ModuleNotFoundError: No module named 'cwsm'
Cannot anybody give me a suggestion why is it happening?
Thanks in advance
The github page shows:
import connexion
So your import is wrong, try using connexion.
Source:
https://github.com/zalando/connexion#running-it

How to manually import a module in python

When i try to run ovirt downloads_disk_snapshot from this link i am getting error as
Traceback (most recent call last):
File "download_disk_snapshots.py", line 22, in <module>
import ovirtsdk4 as sdk
ImportError: No module named ovirtsdk4
Link is https://github.com/oVirt/ovirt-engine-sdk/blob/master/sdk/examples/download_disk_snapshots.py
This guide gives some very useful information on installing python packages.
In your case, you will have to install the oVirt Engine SDK itself before being able to run the example.
Installation instructions are given within the same Github project that you are mentioning:
https://github.com/oVirt/ovirt-engine-sdk/blob/master/sdk/README.adoc#installation

"ImportError: No module" after uploading to IBM-Cloud

So I have a path structure that looks like this:
~/Dropbox/Coding/Python/Chessbotslack/scripts/Flask_interface.py
~/Dropbox/Coding/Python/Chessbotslack/database/spreadsheets.py
The first line of the Flask_interface.py is:
from Chessbotslack.database.spreadsheets import add_game
If I run this from my IDE (PyCharm) it runs just fine; but if I run it from my terminal it throws the error:
Traceback (most recent call last):
File "Flask_interface.py", line 1, in <module>
from Chessbotslack.database.spreadsheets import add_game
ModuleNotFoundError: No module named 'Chessbotslack'
To solve this I did two things:
1) Adding __init__.py to the directories
This did seem to accomplish anything
2) Adding the directory to $PYTHONPATH
In terminal I ran
export PYTHONPATH=$PYTHONPATH:~/Dropbox/Coding/Python
This solved the problem for running it from my terminal, but as expected it did not solve it for my IBM-Cloud. Perhaps it has something to do with the requirements.txt file?
2018-04-16T09:08:45.30+0200 [APP/PROC/WEB/0]ERR File "scripts/Flask_interface.py", line 1, in <module>
2018-04-16T09:08:45.30+0200 [APP/PROC/WEB/0]ERR from Chessbotslack.database.spreadsheets import add_game
2018-04-16T09:08:45.30+0200 [APP/PROC/WEB/0]ERR ImportError: No module named Chessbotslack.database.spreadsheets
Changing to a flat folder structure (every file in the Chessbotslack folder) and changing the import command from:
from Chessbotslack.database.spreadsheets import add_game
to:
from spreadsheets import add_game
solved it. The weird thing is that the IDE (PyCharm) does not recognize this as correct; only after (incorrectly) adding the folder name "Chessbotslack." in front of it the IDE helps out.
Any idea what to do about that?

ModuleNotFoundError: No module named 'bayesnet'

I'm trying to use the OpenBayes module, but the problems start from the very first step :'(
When I try to import from OpenBayes
I get:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Мари\AppData\Local\Programs\Python\Python36\lib\site-packages\OpenBayes\__init__.py", line 7, in <module>
from bayesnet import *
ModuleNotFoundError: No module named 'bayesnet'
UPD: While installing (from .exe file) for py2 i gor error: "could not set a key value" (not a python error, but in dialog window)
I tried using pip install from console, but still get errors there.
Command "python setup.py egg_info" failed with error code 1 in C:\Users\CD3B~1\AppData\Local\Temp\pip-build-m4nnwa4o\OpenBayes\
Also not sure which py (2 or 3) is used when i type a command from console(
(Sorry for all that stupis questions)
You should
from OpenBayes import *
or
from OpenBayes import BNet
Here is an example demonstrating it's usage:
https://github.com/willasaywhat/OpenBayes-Fork/blob/master/Examples/bn_asia.py
I had the same problem and I created a directory with the same name as the root folder (within the root folder). Python then referred Its import calls to the src directory and not the folder. I also changed the python interpreter to a virtual (anaconda.exe), as the python install did not contain many of the modules that were being called by the application (flask, etc)
It's a weird workaround, but it worked for me. Hope this helps

Categories

Resources