Ankit404butfound / PyWhatKit

Send WhatsApp message at certain time and many other things.
MIT License
1.37k stars 298 forks source link

pywhatkit no internet error #135

Closed Vortexano closed 2 years ago

Vortexano commented 3 years ago

C:\Users\vx0105\PycharmProjects\pythonProject1\venv\Scripts\python.exe C:/Users/vx0105/PycharmProjects/pythonProject1/main.py Traceback (most recent call last): File "C:\Users\vx0105\PycharmProjects\pythonProject1\venv\lib\site-packages\urllib3\connectionpool.py", line 706, in urlopen chunked=chunked, File "C:\Users\vx0105\PycharmProjects\pythonProject1\venv\lib\site-packages\urllib3\connectionpool.py", line 382, in _make_request self.validate_conn(conn) File "C:\Users\vx0105\PycharmProjects\pythonProject1\venv\lib\site-packages\urllib3\connectionpool.py", line 1010, in validate_conn conn.connect() File "C:\Users\vx0105\PycharmProjects\pythonProject1\venv\lib\site-packages\urllib3\connection.py", line 426, in connect tls_in_tls=tls_in_tls, File "C:\Users\vx0105\PycharmProjects\pythonProject1\venv\lib\site-packages\urllib3\util\ssl.py", line 450, in ssl_wrap_socket sock, context, tls_in_tls, server_hostname=server_hostname File "C:\Users\vx0105\PycharmProjects\pythonProject1\venv\lib\site-packages\urllib3\util\ssl.py", line 493, in _ssl_wrap_socket_impl return ssl_context.wrap_socket(sock, server_hostname=server_hostname) File "C:\Users\vx0105\AppData\Local\Programs\Python\Python36\lib\ssl.py", line 407, in wrap_socket _context=self, _session=session) File "C:\Users\vx0105\AppData\Local\Programs\Python\Python36\lib\ssl.py", line 817, in init self.do_handshake() File "C:\Users\vx0105\AppData\Local\Programs\Python\Python36\lib\ssl.py", line 1077, in do_handshake self._sslobj.do_handshake() File "C:\Users\vx0105\AppData\Local\Programs\Python\Python36\lib\ssl.py", line 689, in do_handshake self._sslobj.do_handshake() ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\vx0105\PycharmProjects\pythonProject1\venv\lib\site-packages\requests\adapters.py", line 449, in send timeout=timeout File "C:\Users\vx0105\PycharmProjects\pythonProject1\venv\lib\site-packages\urllib3\connectionpool.py", line 756, in urlopen method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2] File "C:\Users\vx0105\PycharmProjects\pythonProject1\venv\lib\site-packages\urllib3\util\retry.py", line 574, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='www.google.com', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)'),))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\vx0105\PycharmProjects\pythonProject1\venv\lib\site-packages\pywhatkit\main.py", line 310, in requests.get("https://www.google.com") File "C:\Users\vx0105\PycharmProjects\pythonProject1\venv\lib\site-packages\requests\api.py", line 75, in get return request('get', url, params=params, kwargs) File "C:\Users\vx0105\PycharmProjects\pythonProject1\venv\lib\site-packages\requests\api.py", line 61, in request return session.request(method=method, url=url, kwargs) File "C:\Users\vx0105\PycharmProjects\pythonProject1\venv\lib\site-packages\requests\sessions.py", line 542, in request resp = self.send(prep, send_kwargs) File "C:\Users\vx0105\PycharmProjects\pythonProject1\venv\lib\site-packages\requests\sessions.py", line 655, in send r = adapter.send(request, kwargs) File "C:\Users\vx0105\PycharmProjects\pythonProject1\venv\lib\site-packages\requests\adapters.py", line 514, in send raise SSLError(e, request=request) requests.exceptions.SSLError: HTTPSConnectionPool(host='www.google.com', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)'),))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:/Users/vx0105/PycharmProjects/pythonProject1/main.py", line 3, in import pywhatkit File "C:\Users\vx0105\PycharmProjects\pythonProject1\venv\lib\site-packages\pywhatkitinit.py", line 8, in from pywhatkit.main import print_sleep_time, check_window, sendwhatmsg, sendwhatmsg_to_group, info, playonyt, search, close_tab, sendwhatmsg_instantly, sendwhats_image File "C:\Users\vx0105\PycharmProjects\pythonProject1\venv\lib\site-packages\pywhatkit\main.py", line 315, in "NO INTERNET - Pywhatkit needs active internet connection") pywhatkit.exceptions.InternetException: NO INTERNET - Pywhatkit needs active internet connection

Process finished with exit code 1

I am encountering this error when I run a programme which I tell to play a song for me, when I run the programme before i even give it any command it says internet error but I have internet access. How can I fix it?

codewithpom commented 3 years ago

@Vortexano Thanks for telling us and we will work on it shortly but can you please send your code and check your internet before running the program.

Vortexano commented 3 years ago

@Vortexano Thanks for telling us and we will work on it shortly but can you please send your code and check your internet before running the program.

import speech_recognition as sr import pyttsx3 import pywhatkit import wikipedia import datetime import pyjokes import requests

listener = sr.Recognizer() engine = pyttsx3.init() voices = engine.getProperty('voices') engine.setProperty('voice', voices[0].id)

def talk(text): engine.say(text) engine.runAndWait()

def take_command(): try: with sr.Microphone() as source: talk("Hi I am Simon") print("Listening.....") voice = listener.listen(source) command = listener.recognize_google(voice) command = command.lower() if 'Simon' in command: command = command.replace('Simon', '') print(command)

except:
    pass
return command

def run_alexa(): command = take_command() print(command) if 'play' in command: song = command.replace('play', '') talk('playing' + song) pywhatkit.playonyt(song) elif 'time' in command: time = datetime.datetime.now().strftime('%I.%M %p') talk('Current time is ' + time) elif 'who is' in command: person = command.replace('Who is', '') info = wikipedia.summary(person, 1) print(info) talk(info) elif 'date' in command: talk('Sorry, I have a headache') elif 'joke' in command: talk(pyjokes.get_joke()) else: talk('Please I beg your pardon')

while True: run_alexa()

This is the program am trying to run, the indentations are correct i dont know why when I paste it here its removing them. My internet is working just fine, am using ethernet cable.

codewithpom commented 3 years ago

@Ankit404butfound and @aaryanrr Please have a look on it, @Vortexano Thanks for reporting this issue if this is a bug or a problem we will surely fix it in the next version.

Ankit404butfound commented 3 years ago

It seems the connection is getting timed out, I am not sure if this is possible but have you disabled network in your virtual environment?

Vortexano commented 3 years ago

It seems the connection is getting timed out, I am not sure if this is possible but have you disabled network in your virtual environment?

How do I check whether network is enabled or not in the virtual environment?

Ankit404butfound commented 3 years ago

Maybe try using it without virtual environment.

Vortexano commented 3 years ago

Maybe try using it without virtual environment.

Traceback (most recent call last):

File "C:\Users\vx0105\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 699, in urlopen httplib_response = self._make_request(

File "C:\Users\vx0105\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 382, in _make_request self._validate_conn(conn)

File "C:\Users\vx0105\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 1010, in _validate_conn conn.connect()

File "C:\Users\vx0105\Anaconda3\lib\site-packages\urllib3\connection.py", line 411, in connect self.sock = ssl_wrap_socket(

File "C:\Users\vx0105\Anaconda3\lib\site-packages\urllib3\util\ssl_.py", line 428, in ssl_wrap_socket ssl_sock = _ssl_wrap_socket_impl(

File "C:\Users\vx0105\Anaconda3\lib\site-packages\urllib3\util\ssl_.py", line 472, in _ssl_wrap_socket_impl return ssl_context.wrap_socket(sock, server_hostname=server_hostname)

File "C:\Users\vx0105\Anaconda3\lib\ssl.py", line 500, in wrap_socket return self.sslsocket_class._create(

File "C:\Users\vx0105\Anaconda3\lib\ssl.py", line 1040, in _create self.do_handshake()

File "C:\Users\vx0105\Anaconda3\lib\ssl.py", line 1309, in do_handshake self._sslobj.do_handshake()

SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1125)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "C:\Users\vx0105\Anaconda3\lib\site-packages\requests\adapters.py", line 439, in send resp = conn.urlopen(

File "C:\Users\vx0105\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 755, in urlopen retries = retries.increment(

File "C:\Users\vx0105\Anaconda3\lib\site-packages\urllib3\util\retry.py", line 574, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause))

MaxRetryError: HTTPSConnectionPool(host='www.google.com', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1125)')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "C:\Users\vx0105.spyder-py3\temp.py", line 10, in import pywhatkit

File "C:\Users\vx0105\Anaconda3\lib\site-packages\pywhatkit__init__.py", line 8, in from pywhatkit.main import print_sleep_time, check_window, sendwhatmsg, sendwhatmsg_to_group, info, playonyt, search, close_tab, sendwhatmsg_instantly, sendwhats_image

File "C:\Users\vx0105\Anaconda3\lib\site-packages\pywhatkit\main.py", line 13, in requests.get('https://www.google.com')

File "C:\Users\vx0105\Anaconda3\lib\site-packages\requests\api.py", line 76, in get return request('get', url, params=params, **kwargs)

File "C:\Users\vx0105\Anaconda3\lib\site-packages\requests\api.py", line 61, in request return session.request(method=method, url=url, **kwargs)

File "C:\Users\vx0105\Anaconda3\lib\site-packages\requests\sessions.py", line 542, in request resp = self.send(prep, **send_kwargs)

File "C:\Users\vx0105\Anaconda3\lib\site-packages\requests\sessions.py", line 655, in send r = adapter.send(request, **kwargs)

File "C:\Users\vx0105\Anaconda3\lib\site-packages\requests\adapters.py", line 514, in send raise SSLError(e, request=request)

SSLError: HTTPSConnectionPool(host='www.google.com', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1125)')))

Tried to run it in Spyder and am now getting this

ns23k commented 3 years ago
requests.get('https://google.com', verify='/path/to/certfile')
# or you can skip verifications by doing this:

requests.get('https://google.com', verify=False)

# You should specify your CA.

source - https://stackoverflow.com/questions/51768496/why-do-https-requests-produce-ssl-certificate-verify-failed-error

ns23k commented 3 years ago

you can try this

ns23k commented 3 years ago

or maybe installing openssl https://www.openssl.org/

aaryanrr commented 2 years ago

@Vortexano, is the issue resolved?

Edit: I am going to close this issue as there is no further update on it.