No module named 'azure.eventhub'; 'azure' is not a package - python

I am trying to execute this example using Python 3.7 with Pycharm and azure-eventhub 1.2.0 package.
When I try to run it, I get this error:
ModuleNotFoundError: No module named 'azure.eventhub'; 'azure' is not a package
This is the problematic line:
from azure.eventhub import EventHubClient, Receiver, Offset
What could be happening?
This is my project interpreter
Using pip freeze:

As I known, there is a case which will cause your issue.
The Python Interpreter searches the available packages, objects and methods in the paths of sys.path in order, you can print the value of the sys.path variable to see the order after import sys.
So if there is a Python script named azure.py prior to the real azure package, you will get the issue ModuleNotFoundError: No module named 'azure.eventhub'; 'azure' is not a package.
Here is my steps to reproduce this issue.
I created a Python script named azure.py in the current path which only have one line code print('pseudo azure package').
Then, I opened my Python interpreter in the current path and type from azure.eventhub import EventHubClient, Receiver, Offset, then to get the issue as below.
It also will happen in Pycharm, even using virtualenv, please check whether exists a file called azure.py or azure.pyc in your current path or the paths in the order of sys.path list.

Related

ModuleNotFoundError: No module named 'tinkoff.invest'; 'tinkoff' is not a package

I have trouble with tinkoff API 2.0.
Venv does not see tinkoff-investments, but it was installed successfully.
What did I try:
downgrade from 3.10 to 3.8 python version
update from 3.10 to 3.10.7
deleted and installed module tinkoff-investments
CODE:
image
from tinkoff.invest import Client
TOKEN = 'my_token'
with Client(TOKEN) as client:
print(client.users.get_accounts())
This error:
ModuleNotFoundError: No module named 'tinkoff.invest'; 'tinkoff' is not a package
may also occur if you have named the main program file you created as tinkoff.py and try to run it as python tinkoff.py or another file has the name tinkoff.py in the same folder from which you run your program. Python will consider your program file as a module and try to find something in it that is naturally not in it. About where Python is looking for modules, see sys.path.
In this case, rename your program file so that its name does not equal with the name of the imported module.
In your case, according to the screenshot, you run the file tinkoff.py, which has this line about import:
from tinkoff.invest import Client
Python sees import and first thing (as described above in documentation at link) Python does is look invest at this file — tinkoff.py, not in module tinkoff you installed in venv or in Python310\Libs\... It looks like Python trying to import the same file into itself and finds only the TOKEN variable and not invest object.
So simply rename your startup file tinkoff.py to something else, for example to tinkoffApp.py, to avoid the similarity of the name with the imported module.

Import Arcpy Module Failing - PyScripter

I am trying to use PyScripter however I can import certain modules however I am unable to successfully import the arcpy library.
I have tried configuring the Environment Variables PYTHONPATH without any success. I know I'm missing something with the the correct path to the python executable.
Thanks for your assistance in advance
The Desktop10.8pth references the following
C:\Program Files (x86)\ArcGIS\Desktop10.8\bin
C:\Program Files (x86)\ArcGIS\Desktop10.8\ArcPy
C:\Program Files (x86)\ArcGIS\Desktop10.8\ArcToolBox\Scripts
Pyscripter is returning the following
import arcpy
ModuleNotFoundError: No module named 'arcpy'
IDLE Shell is returning
Traceback (most recent call last):
File "<pyshell#0>", line 1, in
import arcpy
ModuleNotFoundError: No module named 'arcpy'
Enviromental Varibles
Program Files 86 to ArcGIS
Pyscripter Path
Pyscripter Path Additional
Python Structure
Python27
The message ModuleNotFoundError: No module named 'arcpy' comes from whatever pythonx.y you are running. Do you have more than one python installed on your system? If so, the common error is to install something for one python and try to import it with another.
What you call the 2.7 structure shows Python39-32. Does arcpy run with that version?
If you are trying to run arcpy with python x.y, the pythonx.y directory Lib/site-packages/ must contain the arcpy package or a .pth file pointing to its location. Is Desktop10.8pth a typo version of Desktop10.8.pth. If so, then one of the directories, most likely the one ending in ArcPy must contain either an arcpy package directory or an arcpy.py file.

ImportError: No module named 'kzyvad'

I want to start up a project, which imports a module named kzyvad. It occurs error ImportError: No module named 'kzyvad'. However, if I execute pip install kzyvad, it returns ERROR: Could not find a version that satisfies the requirement kzyvad.
Did someone ever successfully install kzyvad?
I don't know where you found your module but I looked for it and I could not find it, I think the guy who wrote 'kzyvad' did a mistake while writing, and if pip gives you this error, it means it doesn't exist.
If this kzyvad.py is written by you, then keep this file/module in a same folder and do this in main.py file:
from kzyvad import *
You can use it's functions and classes in your main.py file

I got an error when calling kmodes module in python

When calling the kmodes package like this:
# I have also tried
# from kmodes.kmodes import KModes
from kmodes.kprototypes import KPrototypes
ModuleNotFoundError: No module named 'kmodes'
As suggested by #648trindade, all I had to do was install the package. That's not included in Anaconda by default.
I had same issue. It turned out that I named my test file as kmodes.py, and current directory is in sys.path. so python use my test file as the library.
If you have set the system path to some folder having kmodes.py file, just rename your script as something else, everything is fine.
Or you just remove the sys.path line from the code and restart the compiler

Python: installing multiprocessing

I need to import the multiprocessing module in Python 2.5.
I've followed the instructions here exactly: http://code.google.com/p/python-multiprocessing/wiki/Install
make and make test run without errors. I've also edited $PYTHONPATH to include the directory where the package is installed.
But 'import multiprocessing' still says: "ImportError: no module named multiprocessing".
What am I doing wrong? Is there some step missing from these instructions? I haven't installed a Python module before.
Navigate to the directory containing the package then type:
python setup.py install
This info was contained in the INSTALL.txt file.
http://code.google.com/p/python-multiprocessing/source/browse/trunk/INSTALL.txt
perhaps you can try:
import sys
sys.path.append('/path/to/processingdotpylibs/')
import processing

Categories

Resources