I wrote a module consisting of 40 conversions, python 3.7. The module is all def statements with triple quoted HELP info at the beginning. When I try to import it, I get 'ImportError: DLL load failed: %1 is not a valid Win32 application'. I am at a loss as to what to do.
Tried saving as .py and .pyd. Moved file into every environment on my PYTHONPATH. Multitude of google searches, but nothing I could wrap my head around.
Line 1 is:
def main():
pass
in order to make this work:
if __name__ == '__main__':
main()
But was getting same import error before I added these elements.
import cunvurtz
Traceback (most recent call last):
File "P:\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 3296, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "", line 1, in
import cunvurtz
File "P:\PyCharm Community Edition with Anaconda plugin 2019.1.1\helpers\pydev_pydev_bundle\pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
ImportError: DLL load failed: %1 is not a valid Win32 application.
Related
import time
from selenium import webdriver
path = input("enter filepath: ")
driver = webdriver.Firefox(path)
driver.get("htpps://google.com")
This is the part of my code seemingly causing the error, I have been able to find any answers online. The code used to work when using r"c:\users\ellio\desktop\main" however this has since stopped working too, only without the top error. I have added the folder containg geckodriver to path and added the geckodriver exe to the same file as my code, but nothing seems to work.
Thanks in advance for any help.
Here are the errors
Traceback (most recent call last):
File "C:\Users\ellio\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\common\service.py", line 72, in start
self.process = subprocess.Popen(cmd, env=self.env,
File "C:\Users\ellio\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 951, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\ellio\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 1420, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\Users\ellio\Desktop\main\app.py", line 18, in <module>
driver = webdriver.Firefox(path)
File "C:\Users\ellio\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 164, in __init__
self.service.start()
File "C:\Users\ellio\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start
raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
give a specific path of your driver
from selenium import webdriver
driver = webdriver.Chrome('D:\\chrome\\chromedriver.exe') #give location of driver you download
driver.get('http://www.google.com/');
time.sleep(5)
search_box = driver.find_element_by_name('q')
search_box.send_keys('ChromeDriver')
search_box.submit()
time.sleep(5)
driver.quit()
I am trying to use Tensorflow Object Detection API and I follow the steps mentioned in the given link -
https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/install.html#tf-models-install
When I try to access the Object Detection Jupyter Notebook through jupyter notebook
I am facing the below exception
Traceback (most recent call last):
File "/usr/local/bin/jupyter-notebook", line 7, in <module>
from notebook.notebookapp import main
File "/home/dinesh/.local/lib/python3.6/site-
packages/notebook/notebookapp.py", line 79, in <module>
from .base.handlers import Template404, RedirectWithParams
File "/home/dinesh/.local/lib/python3.6/site-
packages/notebook/base/handlers.py", line 32, in <module>
import prometheus_client
File "/home/dinesh/.local/lib/python3.6/site-
packages/prometheus_client/__init__.py", line 7, in <module>
from . import process_collector
File "/home/dinesh/.local/lib/python3.6/site-
packages/prometheus_client/process_collector.py", line 12, in <module>
_PAGESIZE = resource.getpagesize()
AttributeError: module 'resource' has no attribute 'getpagesize'
I am using
Python - 3.6.3
Jupyter - 1.0.0
How can I overcome this exception?
Got a similar error. My project contained modules (folders)
model
resource (replaced with resources)
service
So I changed the name of the resource module to resources (change name to any appropriate module name)
I have the same error ,after rename my resource module in the PYTHONPATH , it works right. check your PYTHONPATH, is there a resource module?
I had a similar issue on starting Jupyter Notebooks on Windows 10.
When I initially ran the regular startup script, I got a windows terminal that opened and immediately closed, too fast to see any error messages. So, I opened a windows 10 powershell terminal and ran
conda update conda
and
conda update --all
then I ran
jupyter-notebook at the windows prompt. The results were:
Traceback (most recent call last):
File "E:\Users\Bob\anaconda3\Scripts\jupyter-notebook-script.py", line 6, in
from notebook.notebookapp import main
File "E:\Users\Bob\anaconda3\lib\site-packages\notebook\notebookapp.py", line 76, in
from .base.handlers import Template404, RedirectWithParams
File "E:\Users\Bob\anaconda3\lib\site-packages\notebook\base\handlers.py", line 24, in
import prometheus_client
File "E:\Users\Bob\anaconda3\lib\site-packages\prometheus_client_init_.py", line 3, in
from . import (
File "E:\Users\Bob\anaconda3\lib\site-packages\prometheus_client\process_collector.py", line 11, in
_PAGESIZE = resource.getpagesize()
AttributeError: module 'resource' has no attribute 'getpagesize'
I opened process_collector.py in the site-packages\prometheus_client in notepad++ and changed
line 9 import resource to import resources
and
line 11 _PAGESIZE = resource.getpagesize() to _PAGESIZE = resources.getpagesize()
I searched for other instances of resource and found none. I then saved the file and reran jupyter-notebook at the windows terminal prompt.
This time I got:
Traceback (most recent call last):
File "E:\Users\Bob\anaconda3\Scripts\jupyter-notebook-script.py", line 10, in
sys.exit(main())
File "E:\Users\Bob\anaconda3\lib\site-packages\jupyter_core\application.py", line 254, in launch_instance
return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
File "E:\Users\Bob\anaconda3\lib\site-packages\traitlets\config\application.py", line 844, in launch_instance
app.initialize(argv)
File "E:\Users\Bob\anaconda3\lib\site-packages\traitlets\config\application.py", line 87, in inner
return method(app, *args, **kwargs)
File "E:\Users\Bob\anaconda3\lib\site-packages\notebook\notebookapp.py", line 2126, in initialize
self.init_resources()
File "E:\Users\Bob\anaconda3\lib\site-packages\notebook\notebookapp.py", line 1697, in init_resources
old_soft, old_hard = resource.getrlimit(resource.RLIMIT_NOFILE)
AttributeError: module 'resource' has no attribute 'getrlimit'
Still having Notepad++ open, I opened notebookapp.py in site-packages\notebook and searched for resource. I found and changed the following lines:
Line 37 import resource to import resources
line 40 resource = None to resources = None
line 1036 resource is None to resources is None
line 1040 soft, hard = resource.getrlimit(resource.RLIMIT_NOFILE) to
soft, hard = resources.getrlimit(resources.RLIMIT_NOFILE)
line 1693 if resource is None: to if resources is None:
line 1697 old_soft, old_hard = resource.getrlimit(resource.RLIMIT_NOFILE) to old_soft, old_hard = resources.getrlimit(resources.RLIMIT_NOFILE)
line 1706 resource.setrlimit(resource.RLIMIT_NOFILE, (soft, hard)) to
resources.setrlimit(resources.RLIMIT_NOFILE, (soft, hard))
I searched for other instances of resource and found none. I then saved the notebookapp.py file and reran jupyter-notebook at the windows terminal prompt. This time Jupyter Notebooks opened with the expected files tab displayed. I quit out of Jupyter Notebooks and restarted using the normal link to the startup script and it worked as expected.
I am not sure what caused this issue. I did not intentionally update anything before I saw the issue. Yesterday, Jupyter Notebooks worked as expected, today when I tried to run it, I got the flicker screen as described above.
[Quick look for root cause]
Check if you have set PYTHONPATH in your system -
try to rename that momentarily
run "jupyter notebook"
[Fix the issue]
if the issue is resolved by doing this then
search "resource" folder within all paths mentioned in PYTHONPATH
if such folder found then rename/refactor it to other name e.g. "resources"
I created the small sample to demonstrate error I'm seeing trying to use pyinstaller to build an executable program. My python is 3.6.5 and is installed /home/repos/ges/Python/bin. I was not sure if the non-standard python install is playing contributing role in error.
import time
import random
from multiprocessing.dummy import Pool as ThreadPool
# A function to run against a list
def this_job(job):
time_delay = random.randrange(0, 5)
time.sleep(time_delay)
print("after a small " + str(time_delay) + " second delay here is job " + str(job))
forked_jobs = []
for i in range(500):
forked_jobs.append(i)
# Make the Pool of workers and do the work
pool = ThreadPool(10)
pool.map(this_job, forked_jobs)
# close the pool and wait for the work to finish
pool.close()
pool.join()
I can run the file from where I wrote it and see output similar to:
after a small 0 second delay here is job 52
after a small 0 second delay here is job 117
after a small 1 second delay here is job 39
after a small 1 second delay here is job 65...
When I try to build this using ./python3 pyinstaller bp2.py and run the executable in the dist folder I see the following error.
Traceback (most recent call last):
File "site-packages/PyInstaller/loader/rthooks/pyi_rth_multiprocessing.py", line 8, in
File "/home/repos/ges/Python/lib/python3.6/site-packages/PyInstaller/loader/pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.dict)
File "multiprocessing/spawn.py", line 19, in
from . import util
File "/home/repos/ges/Python/lib/python3.6/site-packages/PyInstaller/loader/pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.dict)
File "multiprocessing/util.py", line 17, in
from subprocess import _args_from_interpreter_flags
File "/home/repos/ges/Python/lib/python3.6/site-packages/PyInstaller/loader/pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.dict)
File "subprocess.py", line 136, in
File "/home/repos/ges/Python/lib/python3.6/site-packages/PyInstaller/loader/pyimod03_importers.py", line 714, in load_module
module = loader.load_module(fullname)
ImportError: /home/repos/ges/Python/GES_Module/dist/bp2/_posixsubprocess.so: undefined symbol: _Py_set_inheritable_async_safe
[15670] Failed to execute script pyi_rth_multiprocessing
Not sure how to resolve.
It appears I was getting this error as a result of my python build location. I tested the above on a machine with python installed in a typical location and it works as expected.
I am trying to run a voice program with Python 3, like given here: https://stackoverflow.com/a/31257805/760393
But I keep getting errors:
..\site-packages\pyttsx\engine.py, line 18, in import driver..
Please help.
Traceback (most recent call last):
File "C:/Users/USER/AppData/Local/Programs/Python/Python35-32/0DEV/L X/voice2.py", line 1, in <module>
import pyttsx
File "C:\Users\USER\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pyttsx\__init__.py", line 18, in <module>
from .engine import Engine
File "C:\Users\USER\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pyttsx\engine.py", line 18, in <module>
import driver
ImportError: No module named 'driver'
I had this problem. It's a mistake in calling driver.py file in engine.py.
You must edit engine file and at calling section change this:
import driver
to:
from . import driver
Recently, Dill has completely stopped working for me. It does this:
>>> import dill
>>> dill.dumps([1,2,3])
b'\x80\x03]q\x00(K\x01K\x02K\x03e.'
>>> dill.loads(_)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python34\lib\site-packages\dill\dill.py", line 260, in loads
return load(file)
File "C:\Python34\lib\site-packages\dill\dill.py", line 250, in load
obj = pik.load()
File "C:\Python34\lib\pickle.py", line 1039, in load
dispatch[key[0]](self)
File "C:\Python34\lib\pickle.py", line 1066, in load_proto
raise ValueError("unsupported pickle protocol: %d" % proto)
ValueError: unsupported pickle protocol: 93
The number is different every time. This started happening maybe a month ago; reinstalling Dill with pip didn't help.
From stepping through it with a debugger it looks like it's correctly reading in the protocol version from the beginning of the data, then reading one of the first instructions in the pickle data and interpreting it as the protocol version for some reason. I don't really know though, since I don't know much about how pickle works.