Skip to content
Advertisement

Tag: importerror

Struggling with python’s import mechanism

I am an experienced java enterprise developer but very new to python enterprise development shop. I am currently, struggling to understand why some imports work while others don’t. Some background: Our dev team recently upgraded python from 3.6 to 3.10.5 and following is our package structure Now, inside the moduleA.py, I am trying to import subpackage2/moduleZ.py like so But, I

Why is mechanize not installing properly via pip on RPi? (python 3.9)

I can’t get to successfully install the package ‘mechanize’ on a Raspberry Pi (so, ARM chip) with Debian Bullseye, python 3.9 in a virtualenv. When I look in the virtualenv’s sitepackages folder, indeed the mechanize package only has .dist-info file, but not a mechanize.py file or mechanize package folder. See below. Question: Am I overlooking something? Details (1): Installing mechanize

ImportError in test files

I’ve seen a lot of questions that are similar to this but none of the solutions have worked for me. I’m getting an import error when trying to run pytest on a test package I’m developing to teach myself how to create python packages. Currently I have a python package that looks like and my test_module_a.py contains Running the command

“Most likely due to circular import” in Python

Does anyone know why this piece of code returns this error when run and how to fix it? When I run this code in normal IDLE it seems to work but it doesn’t work in Visual Studio Code. Answer It seems like the program file you have created is named threading.py, and you are importing a module also called threading.

Import Error: can’t import name gcd from fractions

I’m trying to import a function called gcd from a module called fractions with from fractions import gcd. For some reason, PyCharm throws an ImportError: I had this working before, what am I doing wrong? Answer Your traceback says Python 3.9 and the documentation says gcd is a function in math Changed in version 3.9: The math.gcd() function is now

ImportError while importing PySide2

I installed PySide2 using pip install PySide2 But i got this error when i tried to import it: Answer Have a look at the PyPI documentation here. If that doesn’t help try to use Make sure it is installede in your virtual environtment if you are using that and you are using the correct version of pip(3). Here is a

Advertisement