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.
Related
When I install package with python and import it, I often get a missing imports message such as:
Import "fastapi" could not be resolvedPylancereportMissingImports
The imports always work perfectly fine, the fastapi example above will run a server and I can build an API without issue.
Can anyone explain why I am getting this error and how I could get rid of it?
Reinstall fastapi again separately.
pip install 'fastapi[all]'
pip install fastapi
pip install uvicorn
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())
I'm trying to use pyscenedetect library on python for videos but I get this error when using the python interface and when I use the command line interface I get the error "ModuleNotFoundError: No module named 'cv2'"
even though I believe I installed both correctly according to the documentations.
I have trying to look for different ways to import opencv for the second error but to no avail. As for the first error i can't find any answers to my problem.
import cv2
import numpy as numpy
import os
import scenedetect
from scenedetect.video_manager import VideoManager
from scenedetect.scene_manager import SceneManager
from scenedetect.frame_timecode import FrameTimecode
from scenedetect.stats_manager import StatsManager
from scenedetect.detectors import ContentDetector
If you have pip you can try
pip install opencv-python
If you have anaconoda, you can try
conda install -c conda-forge opencv
it's probable that you installed it on a different python installation in your PC.
To know where your python installation is you can launch python and:
import sys
sys.path
To get the list of everything you have installed you can:
pip freeze > installed_modules.txt
Try only running
import cv2
So that you can test it
I found the problem. As Ivan was pointing out, the problem was with openCV.
I used the following command:
sudo apt install python3-opencv
I am trying to run some code that has 'import websocket' however I am getting the error: ModuleNotFoundError: No module named 'websocket'
I have Python 3.7.3 and I am running in Spyder (if that makes a difference).
So from other questions/answers I found on here, in my cmd I ran pip install websocket and then also pip install websocket-client when the first one didn't run.
I am still getting the ModuleNotFoundError. Does it matter the location/folder of the code or where I install the pip command in cmd?
My python code starts with these import statements:
import json
import websocket
import traceback
import helper
import ssl
import time as time
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from scipy.interpolate import griddata
from mpl_toolkits.mplot3d import Axes3D
In cmd I ran:
C:\Users\myname>pip install websocket
and also:
C:\Users\myname>pip install websocket-client
The error I am getting is:
File "C:/Users/micki/Downloads/Derbit-Volatility-Visulization-master/Derbit-Volatility-Visulization-master/Volatility Surface Class.py", line 2, in <module>
import websocket
ModuleNotFoundError: No module named 'websocket'
Not sure, as you did not cover how you installed and are using Spyder, though I think it is probably an issue with your environment. You might also find that you are missing the module "helper" as well. There's two easy options as follows:
If you installed and are using Spyder via conda or anaconda, follow their documentation on installing websocket-client to the correct environment found here.
The second option (the preferred option IMHO, as you can use any IDE or text editor going forward), regardless of how you installed Spyder, would be to create a python virtual environment python3 -m venv /path/to/new/virtual/environment, pip install all your dependencies in said environment, then link Spyder's interpreter to the interpereter that was installed when you made the environment. In Spyder, go to Tools -> Preferences -> Python interpreter -> check the "Use the following Python interpreter:" radio button and enter the path to the interpreter from the environment you just created. For reference, see docs on making and using a python venv here.
If the websocket and websocket-client doesn't work, try:
pip install websocket_client
This solved my issue:
sudo pip install websocket-client
Package installed but can't be imported : ModuleNotFoundError: No module named. There's a chance I do not use the module right, Idk (tried from module import *, import module and from module import module). The package I'd like to install is py3dns/ dnspython - I don't care which of them, just trying to make [validate_email('example#example.com',check_mx=True)] work, and in the validate_email's instruction they wrote "check_mx" need pyDNS. I understood pyDNS is not supported anymore in python 3.
validate_email does import DNS which means it only works with PyDNS, not dnspython.
install py3DNS and validate_email with:
sudo -H pip install py3dns validate_email
or on Windows just use admin cmd prompt:
pip install py3dns validate_email
then you can run your code normally
from validate_email import validate_email
is_valid = validate_email('example#example.com', verify=True)