Unable to import str from a module in the same directory.
Project is structured like this:
parent
└───cmds
└───chat_client.py
auth_client.py
In chat_client.py when I try to from cmds.auth_client import sesuser I get ModuleNotFoundError: No module named 'cmds'.
I tried removing the cmds. part, however instead it just gave me ImportError: cannot import name 'sesuser' from 'auth_client' (e:\parent\cmds\auth_client.py).
from auth_client import sesuser
try removing extention '.py'
Related
I am converting a python file to .exe using pyinstaller v5.0.1, but I got this error when I run the exe file:
ModuleNotFoundError: No module named 'reportlab.graphics.barcode.code93'
Note that the python file is working perfectly and I'm not even using code93 in my code.
I have fixed this issue by adding an import for all this libs even if I don't use them:
from reportlab.graphics.barcode import code93
from reportlab.graphics.barcode import code39
from reportlab.graphics.barcode import usps
from reportlab.graphics.barcode import usps4s
from reportlab.graphics.barcode import ecc200datamatrix
I have a folder /example which contains /Libs which further contains different folders /a, /b each containing python libraries. I am trying to run a robot framework code from /example.
The error it shows :
Importing test library 'a' failed: ImportError: No module named 'a'
File "/root/Libs/a/init.py", line 7, in
from a import a_classname
How can I solve this?
import os
import sys
filepath = "path/file/"
sys.path.append(os.path.abspath(filepath))
from a import a_classname
Getting the following error when trying to import a lib that depends on zope
No module named zope.index
my python path is correct (I can import other libs)
I already created an init.py file in the zope folder but it still isnt working so Im not sure what I might be missing
currently using python 3.7
*edit
Error:
File "C:\Users\vitor.valentim\AppData\Local\Programs\Python\Python37\Lib\dedupe\tfidf.py", line 5, in
from .canopy_index import CanopyIndex
File "C:\Users\vitor.valentim\AppData\Local\Programs\Python\Python37\Lib\dedupe\canopy_index.py", line 3, in
from zope.index.text.lexicon import Lexicon
ModuleNotFoundError: No module named 'zope.index'
zope path
zope.index path
The error message No module named zope.index implies that import found a package zope, but then failed to find zope.index (otherwise the error message would be No module named zope).
Try
import zope
print(zope)
and see what that resolves to, something like this often happens if there is something shadowing the package you're trying to import.
I want to import a color module but I am getting the error:
ImportError: No module named 'scripts.UltraColor'
Import code:
from scripts.UltraColor import *
The import code is in pygameTest.py
The problem here, as far as I can see on that screenshot is UltraColor file doesn't have the .py extension, for import to work properly you'll need to rename it from UltraColor to UltraColor.py, otherwise will raise an ImportError exception.
For more information, take a look to this one. Import a python module without the .py extension
I've downloaded pymumble from https://github.com/Robert904/pymumble and saved it to my working directory. I import it with:
from pymumble import pymumble
However, I receive:
ImportError: No module named pymumble
I'm looking at similar code that does this successfully. What am I doing wrong when trying to import this?
As I can see there is no file called pymumble in given repository, if you are looking for this there is a file called mumble.py, try importing
from mumble import mumble
this will work.