ModuleNotFoundError: No module named 'scripts.trio_ircproxy' - python-3.x

I just started getting this error:
ImportError: attempted relative import with no known parent package
My directory structure us:
~/Documents/trio_ircproxy/scripts/trio_ircproxy/system_data.py
and I am running the interpreter from ~/Documents/trio_ircproxy/
(base) ashburry#ashburry-ThinkCentre-M92P:~/Documents/trio_ircproxy$ python3 trio_ircproxy.py
Traceback (most recent call last):
File "trio_ircproxy.py", line 35, in <module>
from scripts.trio_ircproxy.system_data import SystemData as system_data
ModuleNotFoundError: No module named 'scripts.trio_ircproxy'
SystemData is a class I am trying to import.
I was not getting this error before so I do not know what the problem is. Any Help?

I fixed this by putting an __init__.py file in the /scripts/ and /scripts/trio_ircproxy/ directories. The file is blank as I am not sure what to put in the __init__.py file.

Related

ImportError: cannot import name 'cpyHook' from partially initialized module 'pyWinhook'

This has been plaguing me for a while now, and I'm not sure what to do about it. I've tried modifying the init.py pyWinhook script's imports, but to no avail. Here's the whole error:
Traceback (most recent call last):
File "d:\myuser\Documents\Python\evil_programs\keylogger.py", line 6, in <module>
import pyWinhook as pyHook
File "C:\Users\myuser\AppData\Roaming\Python\Python310\site-packages\pyWinhook\__init__.py", line 1, in <module>
from .HookManager import *
File "C:\Users\myuser\AppData\Roaming\Python\Python310\site-packages\pyWinhook\HookManager.py", line 1, in <module>
from . import cpyHook
ImportError: cannot import name 'cpyHook' from partially initialized module 'pyWinhook' (most likely due to a circular import) (C:\Users\myuser\AppData\Roaming\Python\Python310\site-packages\pyWinhook\__init__.py)
Thanks in advance
The way I fixed this is by installing Python 3.8.
Python 3.10 and 3.11 produced this issue.
I got this idea from the executable name on GitHub "pyWinhook-1.6.2.win-amd64-py3.8.exe"
Why it does not work with newer python, I have no clue.

ModuleNotFoundError only on system but not on Colab

The following error is not occurring when I run my code on Colab. And I am facing this error when I try to run on my system
Traceback (most recent call last):
File "program.py", line 224, in <module>
import infun
ModuleNotFoundError: No module named 'infun'
I changed to the directory in which my infun present i.e., infunner at the start of my program program.py
import os
os.chdir('infunner')
And I find no difference in paths of files provided for program execution in both Colab and on my system.
What is the reason for this error?
The file structure is as follows
├───program.py
├───infunner
│ ├───infun
│ ...
...

ModuleNotFoundError: No module named 'dnf'

When I point my python3 bin to /usr/bin/python3.6 I get below error:
[dgaikwad#localhost iqe-core]$ dnf
Traceback (most recent call last):
File "/usr/bin/dnf", line 57, in <module>
from dnf.cli import main
ModuleNotFoundError: No module named 'dnf'
[dgaikwad#localhost iqe-core]$
It is works fine when python3 pointed to /usr/bin/python3.7
Can someone please help me to solve it?

Error while configuring pycharm with odoo-13

I am trying to configure a new project to Odoo on Windows however when I run the project after specifying odoo-bin as the Script path this error appears to my:
Traceback (most recent call last):
File "D:/Odoo 13_20200903/server/odoo-bin", line 5, in <module>
import odoo
File "D:\Odoo 13_20200903\server\odoo\__init__.py", line 75, in <module>
import PyPDF2
ModuleNotFoundError: No module named 'PyPDF2'
Any idea how can it be fixed?
Thanks in Advance
The Python interpreter used differs from the interpreter in which the libraries are loaded, make sure that the required interpreter path, may be inside a venv or another name.

ModuleNotFoundError: No module named lib

I have cloned a GitHub repository: https://github.com/xiaojunxu/SQLNet
I have followed the steps until downloading glove embeddings. On running python extract_vocab.py I get 'no module named lib error'.
The lib file is in the folder
The directory structure is as follows:
SQLNet
==>sqlnet
==>lib
==>__init__
==>dbengine
==>utils.py
==>extract_vocab.py
On executing python extract_vocab.py it gives me the following error:
(sql) C:\Users\khata\SQLNet>python extract_vocab.py
Traceback (most recent call last):
File "extract_vocab.py", line 3, in <module>
from sqlnet.utils import *
File "C:\Users\khata\SQLNet\sqlnet\utils.py", line 2, in <module>
from lib.dbengine import DBEngine
ModuleNotFoundError: No module named 'lib'
lib directory is present with dbengine in it.
I am working in WINDOWS with a python3 environment
I copied and pasted the contents of the dbengine file in utils.py.Which solved the problem
Change it to from .lib.dbengine import DBEngine

Resources