I have installed selenium and I can run it on Python.
When I try and run int on pyCharm I keep getting the errors below. I believe it may have to do with how and where I installed pyCharm, but I can't seem to get it to work.
I am looking for help on how I should be configuring pyCharm so I can run my automation script using Python, Selenium, ChromeDriver, and set it up to be triggered every 24 hours and 5 minutes.
script:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
browser= webdriver.Chrome("D:/Projects/chromedriver.exe")
browser.get("https://url.com/")
formElem= browser.find_element_by_name('email')
formElem.send_keys('ucsb#gmail.com')
zipElem=browser.find_element_by_name('zipcode')
zipElem.send_keys('93101')
EnterNowElem=browser.find_element_by_xpath('//input[#value="Enter Now"]')
#EnterTagElem=browser.find_element_by_class_name("")
EnterNowElem.click()
I get the errors below.
"C:\Program Files (x86)\Python36-32\python.exe"
C:/Users/rxper/Desktop/PycharmProjects/Automation/formsubmit.py
Traceback (most recent call last):
File "C:/Users/rxper/Desktop/PycharmProjects/Automation/formsubmit.py", line 1, in <module>
from selenium import webdriver
File "C:\Program Files (x86)\Python36-32\lib\site-packages\selenium\webdriver\__init__.py", line 18, in <module>
from .firefox.webdriver import WebDriver as Firefox # noqa
File "C:\Program Files (x86)\Python36-32\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 19, in <module>
import http.client as http_client
File "C:\Program Files (x86)\Python36-32\lib\http\client.py", line 71, in <module>
import email.parser
File "C:\Users\rxper\Desktop\PycharmProjects\Automation\email.py", line 31
'Subject: So long.\nDear Alice, so long and thanks for all the fish. Sincerely,
^
SyntaxError: EOL while scanning string literal
Process finished with exit code 1
You problem is below
File "C:\Users\rxper\Desktop\PycharmProjects\Automation\email.py"
and
File "C:\Program Files (x86)\Python36-32\lib\http\client.py", line 71, in <module>
import email.parser
Python has a internal module email and your Automation\email.py is overshadowing the same. Rename the file and it should work
Related
I'm trying to create an exe out of my Python script. After a long journey of problem solving, I finally made it with Pyinstaller. I got a build folder, a dist folder, and the needed exe file.
Now, when I try to run the program, it doesn't work, although it does work in my IDE, PyCharm. If I just click on it, the cmd just opens for a ms and closes right away. If I start it via the cmd, it shows the error you can see below.
Normally there should be a main_window generated by my script, and like I said, it works when I start it from pycharm directly, so the code shouldn't be the problem.
I need the program on another PC without Pycharm at all, so I definitely need this exe file. I hope you can help me. Thanks in advance!
This is the error:
C:\Users\messlaptop\PycharmProjects\Source_code\dist\main_>main_.exe
Traceback (most recent call last):
File "main_.py", line 7, in <module>
import torch
File "C:\Users\messlaptop\PycharmProjects\Source_code\dist\main_\torch\__init__.py", line 643, in <module>
from .functional import * # noqa: F403
File "C:\Users\messlaptop\PycharmProjects\Source_code\dist\main_\torch\functional.py", line 6, in <module>
import torch.nn.functional as F
File "C:\Users\messlaptop\PycharmProjects\Source_code\dist\main_\torch\nn\__init__.py", line 1, in <module>
from .modules import * # noqa: F403
File "C:\Users\messlaptop\PycharmProjects\Source_code\dist\main_\torch\nn\modules\__init__.py", line 2, in <module>
from .linear import Identity, Linear, Bilinear, LazyLinear
File "C:\Users\messlaptop\PycharmProjects\Source_code\dist\main_\torch\nn\modules\linear.py", line 6, in <module>
from .. import functional as F
File "C:\Users\messlaptop\PycharmProjects\Source_code\dist\main_\torch\nn\functional.py", line 11, in <module>
from .._jit_internal import boolean_dispatch, _overload, BroadcastingList1, BroadcastingList2, BroadcastingList3
File "C:\Users\messlaptop\PycharmProjects\Source_code\dist\main_\torch\_jit_internal.py", line 28, in <module>
import torch.package._mangling as package_mangling
File "C:\Users\messlaptop\PycharmProjects\Source_code\dist\main_\torch\package\__init__.py", line 11, in <module>
from .package_exporter import EmptyMatchError, PackageExporter, PackagingError
File "C:\Users\messlaptop\PycharmProjects\Source_code\dist\main_\torch\package\package_exporter.py", line 5, in <module>
import pickletools
ModuleNotFoundError: No module named 'pickletools'
[8896] Failed to execute script 'main_' due to unhandled exception!
I'm trying to automate whatsapp using python in my android phone. I'm using pydroid 3 ide to do it.
From the terminal I installed pywhatkit
$ pip install pywhatkit
And i logged into whatsapp web from chrome browser.
Now I've write the script named test.py like this -
import pywhatkit
pywhatkit.sendwhatmsg("+9176xxxxxx18","hello","10,36")
(My number imstead of +9176xxxxxxxx18)
(I've set the time 2 minutes later from my time)
But whenever I run the script it throws an error in importing pywhatkit
Something like this -
Traceback (most recent call last):
File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 31, in <module>
start(fakepyfile,mainpyfile)
File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 30, in start
exec(open(mainpyfile).read(), __main__.__dict__)
File "<string>", line 1, in <module>
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/site-packages/pywhatkit/__init__.py", line 8, in <module>
from pywhatkit.main import print_sleep_time, check_window, sendwhatmsg, sendwhatmsg_to_group, info, playonyt, search, close_tab, sendwhatmsg_instantly, sendwhats_image
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/site-packages/pywhatkit/main.py", line 9, in <module>
import pyautogui as pg
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/site-packages/pyautogui/__init__.py", line 249, in <module>
import mouseinfo
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/site-packages/mouseinfo/__init__.py", line 223, in <module>
_display = Display(os.environ['DISPLAY'])
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8/os.py", line 675, in __getitem__
raise KeyError(key) from None
KeyError: 'DISPLAY'
[Program finished]
Image :- enter image description here
I can't understand why I'm getting this error please help me.let me know if there any other way to send whatsapp messege using python on android? I also have a terminal termux on my android which runs on linux into bash [my desi terminal 😂]
I see you are trying to run from mobile[android] device, this module requires PC browser. So it wont be able to run in your mobile. Try running test.py through your PC. And you cant send whatsapp messege using python on android.
I was trying to execute the following command on windows 10 machine using python 3.5.4,
from pywinauto.application import Application
Following is the error which i was receiving
Traceback (most recent call last):
File "C:/Users/bizact/Desktop/PSAV/test.py", line 1, in <module>
from pywinauto.application import Application
File "C:\Program Files\Python35\lib\site-packages\pywinauto\__init__.py", line 72, in <module>
from . import findwindows
File "C:\Program Files\Python35\lib\site-packages\pywinauto\findwindows.py", line 42, in <module>
from . import controls
File "C:\Program Files\Python35\lib\site-packages\pywinauto\controls\__init__.py", line 36, in <module>
from . import uiawrapper # register "uia" back-end (at the end of uiawrapper module)
File "C:\Program Files\Python35\lib\site-packages\pywinauto\controls\uiawrapper.py", line 46, in <module>
from ..uia_defines import IUIA
File "C:\Program Files\Python35\lib\site-packages\pywinauto\uia_defines.py", line 35, in <module>
import comtypes.client
File "C:\Program Files\Python35\lib\site-packages\comtypes\client\__init__.py", line 33, in <module>
gen_dir = _find_gen_dir()
File "C:\Program Files\Python35\lib\site-packages\comtypes\client\_code_cache.py", line 71, in _find_gen_dir
result = os.path.abspath(gen_path[-1])
IndexError: list index out of range
Is there a way i can fix this ?
Try running the script with administrative privileges. Just by looking at the traceback it looks like some cached files that pywinauto import tried to write but later on it wasn't found, and generally the script can't write the file due to permissions. If the above don't work, try installing python somewhere else (C:/Python with full privileges in order to isolate the issue)
This is comtypes issue. It will be fixed soon (EDIT: fixed in comtypes==1.1.7). You can downgrade to one of previous versions: pip install comtypes==1.1.2. Or run script as Administrator as Rodolfo suggested (disabling UAC may not help, need to say explicitly to "run as Administrator" by popup menu).
I get an error when I try to start an exe file with pywinauto. This is my code:
from pywinauto.application import Application
app = Application()
app.Start("D:\dragonboy160\dragonboy160.exe")
As far as I know that should work. app = Application().start("") does not work either. I also tried setting the imports like this: from pywinauto import Application I get this error when I run the python file in PyCharm:
"C:\Program Files (x86)\python.exe" D:/dragonboy160/screenview.py
Traceback (most recent call last):
File "D:/dragonboy160/screenview.py", line 2, in <module>
import pywinauto
File "C:\Program Files (x86)\lib\site-packages\pywinauto\__init__.py", line 40, in <module>
from . import findwindows
File "C:\Program Files (x86)\lib\site-packages\pywinauto\findwindows.py", line 42, in <module>
from . import controls
File "C:\Program Files (x86)\lib\site-packages\pywinauto\controls\__init__.py", line 36, in <module>
from . import uiawrapper # register "uia" back-end (at the end of uiawrapper module)
File "C:\Program Files (x86)\lib\site-packages\pywinauto\controls\uiawrapper.py", line 44, in <module>
from ..uia_defines import IUIA
File "C:\Program Files (x86)\lib\site-packages\pywinauto\uia_defines.py", line 35, in <module>
import comtypes.client
File "C:\Program Files (x86)\lib\site-packages\comtypes\client\__init__.py", line 33, in <module>
gen_dir = _find_gen_dir()
File "C:\Program Files (x86)\lib\site-packages\comtypes\client\_code_cache.py", line 71, in _find_gen_dir
result = os.path.abspath(gen_path[-1])
IndexError: list index out of range
I searched and searched and it seems no other person has had this problem. I also tried opening other .exe files but got the same error. What is causing this error and how can I fix it?
This is an import problem (at the very first line).
This looks like comtypes can't write cached files to Program files without admin privileges. In theory it might be fixed on comtypes side (or by re-installing Python to another folder like C:\Python3x), but you will have to run the script as Administrator anyway because of other OS restrictions (pywinauto will warn about insufficient rights in nearest future, now it's silent).
I had the same problem and I managed to have it fixed by disabling UAC from Windows.
I am new to Python and am trying to use anaconda to do some data analysis. I am using Python 3.6.2 along with the geany text editor.
First, I'm trying to execute a file call panda.py which only contains import pandas as dp.
When I configure geany with a working directory of C:\Users\Anaconda3\python, I get the following error:
Traceback (most recent call last):
File "panda.py", line 1, in <module>
import pandas as dp
File "C:\Users\Anaconda3\lib\site-packages\pandas\__init__.py", line 13, in <module>
__import__(dependency)
File "C:\Users\Anaconda3\lib\site-packages\numpy\__init__.py", line 142, in <module>
from . import add_newdocs
File "C:\Users\Anaconda3\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "C:\Users\Anaconda3\lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
from .type_check import *
File "C:\Users\Anaconda3\lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "C:\Users\Anaconda3\lib\site-packages\numpy\core\__init__.py", line 35, in <module>
from . import _internal # for freeze programs
File "C:\Users\Anaconda3\lib\site-packages\numpy\core\_internal.py", line 18, in <module>
from .numerictypes import object_
File "C:\Users\Anaconda3\lib\site-packages\numpy\core\numerictypes.py", line 962, in <module>
_register_types()
File "C:\Users\Anaconda3\lib\site-packages\numpy\core\numerictypes.py", line 958, in _register_types
numbers.Integral.register(integer)
AttributeError: module 'numbers' has no attribute 'Integral'
The same error also occurs when I enter the following at the command prompt:
C:\Users\Anaconda3\python.exe C:\Users\Documents\python_work\panda.py
However, if I execute C:\Users\David\Anaconda3\python.exe and then enter import pandas as dp in the REPL, it appears to load without error.
Any idea how I can fix this so I can use anaconda with geany?
[SOLVED] John below ask if I had a file called numbers.py in my directory which made me realize I named an exercise I previously did as numbers.py. Once I removed it, the error went away (I tested it further by adding a file with the name again and the error returned).
I'm new to the stack over flow community. Let me know if there's anything else I need to do to close out this question.
Also thanks to chb for the edits to my original question the format looks much easier to read.
Disclaimer: python on windows is not something I know about
You know that C:\Users\David\Anaconda3\python.exe when run standalone knows how to import pandas, so your setup is fine - you have everything installed that you need, and in the correct locations.
Given that, you can look at two issues: gearny setup, and general setup. I noticed that python and pandas is installed under C:\Users\Anaconda3, while your program is under C:\Users\Documents\python_work, and we also have C:\Users\David - could it be permissions issues?