ModuleNotFoundError: No module named 'dnspython' - python

I am trying to import the module dnspython in a python 3.6 script using import dnspython.
pip3 freeze shows that the package is installed but I keep getting the error ModuleNotFoundError: No module named 'dnspython'
I have tried:
pip3 install dnspython
uninstalling and reinstalling with pip3
pip3 install git+https://github.com/rthalley/dnspython
Cloning the package from github and installing with sudo python setup.py install
pip3 install dnspython3 and using import dnspython3 in the script
Copying the dns folder of the cloned package in the site-packages folder
I am aware of this post for python 2.7 but none of the solutions worked.

The problem was import dnspython. Changing it into import dns worked fine.
Some test code:
import dns
result = dns.resolver.query('google.com', 'A')
for ipval in result:
print('IP', ipval.to_text())
# Output: IP {your ip}

It worked for me (Python 3.8.5):
pip install dnspython3
code:
import dns
from dns import resolver
result = resolver.resolve('google.com')
for ipval in result:
print('IP', ipval.to_text())

Related

Module Not found error: office365 not found

I have seen this issue with some resolutions already, but none have worked for my issue. I have pip installed the latest version of office365(v 2.2.0) to my knowledge using the command:
pip install office365-rest-client
I am trying to import using the following lines of code:
from office365.runtime.auth.authentication_context import AuthenticationContext
from office365.sharepoint.client_context import ClientContext
from office365.sharepoint.files.file import File
I receive the following error:
ModuleNotFoundError: No module named 'office365'
Just to test it out, I uninstalled and reinstalled pandas, then successfully imported pandas into my project.
Install this
pip install Office365-REST-Python-Client
pip install office365
After that, restart your IDE and errase and write again the imports. I no have idea why this worked for me
ATTENTION - You must make the letter O lowercase in both install commands, as below. Capital O does not work.
pip install office365-REST-Python-Client
pip install office365
You also need to install the office365 library as well as office365-rest-client
pip install office365

ModuleNotFoundError: No module named 'fyers_api'

I am running the below code to connect fyers API:
from fyers_api import accessToken
from fyers_api import fyersModel
app_id = "app_id"
app_secret = "secret_id"
app_session = accessToken.SessionModel(app_id, app_secret)
response = app_session.auth()
But still getting error:
ModuleNotFoundError: No module named 'fyers_api'
Please help to resolve issue. I did install fyers_api module. pip install fyers_api
Since this is Python 3 (because ModuleNotFoundError is specific to Python 3), you should be using pip3 instead of pip to install packages:
pip3 install fyers_api
pip install fyers_api will install it for Python 2.
Download fyers api package from here
For Anaconda-3 run below command from the anaconda prompt.
pip install <path to the downloaded package>

Issue installing zenipy, ModuleNotFoundError: no module named 'gi'

I'm trying to import zenipy for windows 10 after reading and experiencing that zenity-python simply will not work. So I installed zenipy and got the 'successfully installed' message from the command line but now when trying to import it I get :
ModuleNotFoundError: No module named 'gi'
in PyCharm I am writing:
from zenipy import *
Please can someone help me to import zenipy and tell me what is going wrong?
Looks like it's not installed or don't have the dependencies that need. Try pip uninstall zenipy and then pip install zenipy.
Or download and install the repo on GitHub.
$ git clone https://github.com/poulp/zenipy.git
$ cd ./zenipy
$ python setup.py install

pyinstaller No module named grpc

My goal is to build an executable using pyinstaller. The python script I am trying to build imports grpc. The following is an example that illustrates the problem called hello.py.
import grpc
if __name__ == '__main__':
print "hello world"
I do pyinstaller hello.py and that produces the expected dist directory. Then I run it like ./dist/hello/hello and I get error ImportError: No module named grpc.
So then I installed grpc using pip install grpc. When I rebuild the artifact I now get error Import grpc:No module named gevent.socket.
Reading online indicated that the correct items to install were actually grpcio and grpcio-tools. So I tried pip uninstall grpc pip install grpcio and pip install grpcio-tools. Doing this and rebuilding the artifact gave me error ImportError: No module named pkg_resources. Trying to pip install pkg_resources gives error: Could not find a version that satisfies the requirement pkg_resources
Having all grpcio grpcio-tools and grpc install gives the same error: Import grpc:No module named gevent.socket
This seems like it should be a very simple task. I simply want to use pyinstaller to build an artifact that has a dependency on grpc, how do I do this?
I faced the same issue. I referred this document: gRPC
As per the documentation, first upgrade your pip to version 9 or higher.
Then use the following commands:
$ python -m pip install grpcio
$ python -m pip install grpcio-tools
It worked for me!
I am working on doing a PyInstaller/cx_freeze distributable of a python app using grpc.
Can you try adding --hidden-import=pkg_resources and see what happens?
This solved it for me

Error import python-pushover

I am currently running python 2.7.
I already installed python-pushover.
But when I try to import following code
from pushover import init, Client'
I get following error
from pushover import init, Client
ImportError: cannot import name init
I have tried
import pushover
from pushover import init, Client
same error.
My guess is that you did pip install pushover. However, this will install a different package from the one you are interested in. Instead, you will need to uninstall that package:
pip uninstall pushover
and install the correct package:
pip install python-pushover
Once you do that, your code should work as expected.

Categories