I'm quite new to phyton and I've just finished my first application.
Now, I'm trying to compile my .py file to an .exe buy that doestn seem to work.
I've looked everywhere for a solutio to my problem, but I just cant seem to find one.
When I run this command: pyinstaller gui.py
this error shows up:
4815 INFO: Loading module hooks...
4815 INFO: Loading module hook "hook-encodings.py"...
4913 INFO: Loading module hook "hook-pydoc.py"...
4913 INFO: Loading module hook "hook-PyQt5.py"...
5019 WARNING: Hidden import "PyQt5.sip" not found!
5019 INFO: Loading module hook "hook-PyQt5.QtCore.py"...
5096 WARNING: Unable to find Qt5 translations C:/qt5b/qt_1524647842210/_h_env/Library/translations\qtbase_*.qm. These translations were not packaged.
5096 INFO: Loading module hook "hook-PyQt5.QtGui.py"...
Traceback (most recent call last):
File "c:\users\ivo\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\users\ivo\anaconda3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\Ivo\Anaconda3\Scripts\pyinstaller.exe\__main__.py", line 9, in <module>
File "c:\users\ivo\anaconda3\lib\site-packages\PyInstaller\__main__.py", line 111, in run
run_build(pyi_config, spec_file, **vars(args))
File "c:\users\ivo\anaconda3\lib\site-packages\PyInstaller\__main__.py", line 63, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "c:\users\ivo\anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 838, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "c:\users\ivo\anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 784, in build
exec(text, spec_namespace)
File "<string>", line 17, in <module>
File "c:\users\ivo\anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 241, in __init__
self.__postinit__()
File "c:\users\ivo\anaconda3\lib\site-packages\PyInstaller\building\datastruct.py", line 158, in __postinit__
self.assemble()
File "c:\users\ivo\anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 500, in assemble
module_hook.post_graph()
File "c:\users\ivo\anaconda3\lib\site-packages\PyInstaller\building\imphook.py", line 410, in post_graph
self._load_hook_module()
File "c:\users\ivo\anaconda3\lib\site-packages\PyInstaller\building\imphook.py", line 377, in _load_hook_module
self.hook_module_name, self.hook_filename)
File "c:\users\ivo\anaconda3\lib\site-packages\PyInstaller\compat.py", line 736, in importlib_load_source
return mod_loader.load_module()
File "<frozen importlib._bootstrap_external>", line 399, in _check_name_wrapper
File "<frozen importlib._bootstrap_external>", line 823, in load_module
File "<frozen importlib._bootstrap_external>", line 682, in load_module
File "<frozen importlib._bootstrap>", line 265, in _load_module_shim
File "<frozen importlib._bootstrap>", line 684, in _load
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "c:\users\ivo\anaconda3\lib\site-packages\PyInstaller\hooks\hook-PyQt5.QtGui.py", line 11, in <module>
hiddenimports, binaries, datas = add_qt5_dependencies(__file__)
File "c:\users\ivo\anaconda3\lib\site-packages\PyInstaller\utils\hooks\qt.py", line 514, in add_qt5_dependencies
more_binaries = qt_plugins_binaries(plugin, namespace=namespace)
File "c:\users\ivo\anaconda3\lib\site-packages\PyInstaller\utils\hooks\qt.py", line 132, in qt_plugins_binaries
pdir = qt_plugins_dir(namespace=namespace)
File "c:\users\ivo\anaconda3\lib\site-packages\PyInstaller\utils\hooks\qt.py", line 117, in qt_plugins_dir
""".format(namespace, ", ".join(paths)))
Exception:
Cannot find existing PyQt5 plugin directories
Paths checked: C:/qt5b/qt_1524647842210/_h_env/Library/plugins
My path variable:
C:\Users\Ivo\Anaconda3;C:\Users\Ivo\Anaconda3\Library\mingw-w64\bin;C:\Users\Ivo\Anaconda3\Library\usr\bin;C:\Users\Ivo\Anaconda3\Library\bin;C:\Users\Ivo\Anaconda3\Scripts;C:\Users\Ivo\AppData\Local\Programs\Python\Python36-32\Scripts\;C:\Users\Ivo\AppData\Local\Programs\Python\Python36-32\;C:\Users\Ivo\AppData\Local\Microsoft\WindowsApps;C:\Users\Ivo\AppData\Roaming\Composer\vendor\bin;C:\Users\Ivo\AppData\Local\atom\bin;C:\scrcpy-windows-v1.0\adb.exe;D:\xampp2\php;C:\Users\Ivo\AppData\Roaming\npm;
Ive been trying to fix this for a whole day now, if anyone could help me/ point me in the right direction that would be greatly appericiated.
edit:
Also, since i've reinstalled some things to try and fix the problem. the file wont start and gives this error:
Traceback (most recent call last):
File "C:\Users\Ivo\Documents\temp\project\gui.py", line 9, in <module>
from PyQt5 import QtCore, QtGui, QtWidgets
ImportError: DLL load failed: The specified procedure could not be found.
Conda 4.5.11,
Python 3.6.4,
PyInstaller 3.4
The plugin path is determined incorrectly in hooks/qt.py. Qt requires that QCoreApplication is instantiated first, before any other calls.
My qt.py hook is in ~\anaconda3\Lib\site-packages\PyInstaller\utils\hooks\qt.py.
I edited it like so:
json_str = exec_statement("""
import sys
# exec_statement only captures stdout. If there are
# errors, capture them to stdout so they can be displayed to the
# user. Do this early, in case PyQt5 imports produce stderr
# output.
sys.stderr = sys.stdout
import json
from %s.QtCore import QLibraryInfo, QCoreApplication
# QLibraryInfo isn't always valid until a QCoreApplication is
# instantiated.
app = QCoreApplication([])
paths = [x for x in dir(QLibraryInfo) if x.endswith('Path')]
location = {x: QLibraryInfo.location(getattr(QLibraryInfo, x))
for x in paths}
try:
version = QLibraryInfo.version().segments()
except AttributeError:
version = None
print(str(json.dumps({
'isDebugBuild': QLibraryInfo.isDebugBuild(),
'version': version,
'location': location,
})))
""" % self.namespace)
see 1.
Try the fix in Exception: Cannot find PyQt5 plugin directories when using Pyinstaller despite PyQt5 not even being used. In short:
pip intall PyQt5
Note that, strangely enough, conda install PyQt5 may not fix the problem.
I encountered the same problem and saw another suggestion: make the missing directory (C:/qt5b/qt_1524647842210/_h_env/Library/plugins in your case) and copy the two files pyqt5.dll and pyqt5qmlplugin.dll (presumably somewhere in c:\Users[name]\AppData\Local\conda\conda\envs) to the directory.
I did not try it since I fixed the problem with pip install PyQt5. You may want to give it a try.
I am using Python 3.6.3 with ANACONDA3 and Spyder as IDE. Pyinstaller 3.4.
Trying to generate an exe file with Pyinstaller, I had two kinds of errors:
"AttributeError: 'str' object has no attribute 'items' ". This was resolved by
updating each module imported in the Python script, with :
pip install --upgrade <module_name>
"Cannot find existing PyQt5 plugin directories" :this was the next error. As
mentioned by cong yu in his previous post, I fixed this problem by running
pip install PyQt5
Do not forget to upgrade setuptools to the latest version as well
The process delivered an exe file which I have not yet tested.
But at least, I got Pyinstaller reaching the end without failing in error.
Hope this could be helpful
And, by the way, Happy New Year :)
Edit:
I have tested the standalone .exe produced by py2exe
The program is running and get to the end without errors.
But the problem is that xlsx is no more running, because no Excel
files are created. These files are based on pandas dataframes.
My hint is that pandas module, which is the main core of the program,
seems to be altered. I noticed that the dataframes used were truncated,
through the control lines edited in the Ipython console in Spyder.
I think that my best alternative is to reinstall Anaconda3.
So be careful, upgrading the modules used in the program you want as
standalone with py2exe. It seems that upgrading pandas module was a
mistake.
I am sorry, if I gave a bad advice in my main post, but upgrading was the
best way to run py2exe. Be careful with the upgrade of pandas.
Try uninstalling Anaconda. There have been issues in the past. If not you can try py2exe that is fairly decent too.
I installed the latest version of PyInstaller, then this exception of "Cannot find existing PyQt5 plugin directories" is addressed.
You can install the latest version of PyInstaller through the following command:
pip install https://github.com/pyinstaller/pyinstaller/tarball/develop
P.S: Some information about my setup:
$conda info
conda version : 4.6.14
conda-build version : 3.17.8
python version : 3.7.3.final.0
platform : win-64
user-agent : conda/4.6.14 requests/2.21.0 CPython/3.7.3 Windows/10 Windows/10.0.17763
$ pip show pyinstaller
Name: PyInstaller
Version: 3.5.dev0+d74052489
Summary: PyInstaller bundles a Python application and all its dependencies into a single package.
Related
I want to create a Windows executable using PyInstaller.
My project has the following dependencies:
deepspeech
PyAudio (which in turn depends on the PortAudio C library)
tkinter
I tried building the executable by running the command below:
pyinstaller entrypoint.py --name speech-to-text-gui --onedir --hidden-import numpy.random.common --hidden-import numpy.random.bounded_integers --hidden-import numpy.random.entropy
I initially tried building without any --hidden-import arguments, but then I would get errors like
ModuleNotFoundError: No module named 'numpy.random.common'
After the build, when I run the executable, it crashes with the following traceback:
Traceback (most recent call last):
File "entrypoint.py", line 1, in
from speech_to_text_gui.__main__ import main
File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
File "speech_to_text_gui\__main__.py", line 5, in
from speech_to_text_gui import speech_to_text_gui
File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
File "speech_to_text_gui\speech_to_text_gui.py", line 16, in
from deepspeech import Model
File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
File "deepspeech\__init__.py", line 23, in
File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
File "deepspeech\impl.py", line 13, in
ImportError: DLL load failed: The specified module could not be found.
[12236] Failed to execute script 'entrypoint' due to unhandled exception!
The program runs fine when I run it directly with python entrypoint.py.
I looked through the PyInstaller "If Things Go Wrong" page but nothing jumped out at me as wrong with how I am building.
I also tried building on Linux, and the executable built and ran just fine without any runtime errors on Linux.
From the traceback, my guess is loading a DLL for deepspeech failed, since that is the last call in the traceback. But take that with a grain of salt.
I am looking for any suggestions anyone might have to troubleshoot this build.
This is my first StackOverflow post!
I am running into issues creating a pyinstaller(v4.2) executable with a pyzmq (v22.0.2) dependency. I created an executable by running "pyinstaller main.py". The dist folder was created without errors but when I run the executable in the terminal, I see the error in quotes below.
I did a search for this kind of issue on StackOverflow and pyinstaller's documentation with no match to my exact problem. I saw mention of a .spec file for what seemed like similar issues, though I am not sure if this is the way to go since I am unclear what pyzmq.libs\.load_order is.
Does anyone know how to overcome this error or have good leads on what I may try?
"C:\Users\[redacted path]\dist\main>main.exe
Traceback (most recent call last):
File "main.py", line 1, in <module>
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 531, in exec_module
File "zmq\__init__.py", line 19, in <module>
File "zmq\__init__.py", line 13, in _delvewheel_init_patch_0_0_9
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\[redacted path]\\dist\\main\\pyzmq.libs\\.load_order'
[4408] Failed to execute script main
C:\Users\[redacted path]\dist\main>"
I had the same problem and found this solution
Downgrade to 21.0.0 using pip install pyzmq==21.0.0
then you can run pyinstaller again and it will run perfectly fine.
Find a folder called 'pyzmq.libs' in your <local-python-path>\Lib\site-packages.
For example, I'm using Miniconda3 here, so I got this at C:\\Users\MyPC\Miniconda3\envs\my_env\Lib\site-packages
Then, copy this folder to your C:\\Users\\[redacted path]\\dist\\main folder, and re-try the executable.
I am new programming and when I tried to convert my .py file to an executable .exe file I get the following ERROR.
My numpy version is 1.19.1 (I have already uninstalled it and installed it again).
My Anaconda version is 1.9.12
PYTHONPATH is OK.
The error is the following when trying to get the .exe file:
Running auto-py-to-exe v2.7.6
Building directory: C:\Users\User\AppData\Local\Temp\tmp30rpmpfm
Provided command: pyinstaller --noconfirm --onedir --windowed "C:/Users/User/Documents/Python/Scripts/Italiano/conjugacion_verbos_presente/auxiliar.py"
Recursion Limit is set to 5000
Executing: pyinstaller --noconfirm --onedir --windowed C:/Users/User/Documents/Python/Scripts/Italiano/conjugacion_verbos_presente/auxiliar.py --distpath C:\Users\User\AppData\Local\Temp\tmp30rpmpfm\application --workpath C:\Users\User\AppData\Local\Temp\tmp30rpmpfm\build --specpath C:\Users\User\AppData\Local\Temp\tmp30rpmpfm
520727 INFO: PyInstaller: 3.6
520732 INFO: Python: 3.7.6 (conda)
520736 INFO: Platform: Windows-10-10.0.18362-SP0
520746 INFO: wrote C:\Users\User\AppData\Local\Temp\tmp30rpmpfm\auxiliar.spec
520753 INFO: UPX is not available.
520761 INFO: Extending PYTHONPATH with paths
['C:\\Users\\User\\Documents\\Python\\Scripts\\Italiano',
'C:\\Users\\User\\AppData\\Local\\Temp\\tmp30rpmpfm']
520765 INFO: checking Analysis
520769 INFO: Building Analysis because Analysis-01.toc is non existent
520774 INFO: Reusing cached module dependency graph...
520878 INFO: Caching module graph hooks...
521005 INFO: running Analysis Analysis-01.toc
521011 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
required by C:\Anaconda3\python.exe
521620 INFO: Analyzing C:\Users\User\Documents\Python\Scripts\Italiano\conjugacion_verbos_presente\auxiliar.py
527431 INFO: Processing pre-find module path hook distutils
527438 INFO: distutils: retargeting to non-venv dir 'C:\\Anaconda3\\lib'
533043 INFO: Processing pre-safe import module hook setuptools.extern.six.moves
534572 INFO: Processing pre-find module path hook site
534577 INFO: site: retargeting to fake-dir 'C:\\Anaconda3\\lib\\site-packages\\PyInstaller\\fake-modules'
547576 INFO: Processing module hooks...
547582 INFO: Loading module hook "hook-distutils.py"...
547591 INFO: Loading module hook "hook-encodings.py"...
547763 INFO: Loading module hook "hook-importlib_metadata.py"...
547772 INFO: Loading module hook "hook-lib2to3.py"...
547785 INFO: Loading module hook "hook-numpy.core.py"...
An error occurred while packaging
Traceback (most recent call last):
File "C:\Anaconda3\lib\site-packages\numpy\core\__init__.py", line 24, in <module>
from . import multiarray
File "C:\Anaconda3\lib\site-packages\numpy\core\multiarray.py", line 14, in <module>
from . import overrides
File "C:\Anaconda3\lib\site-packages\numpy\core\overrides.py", line 7, in <module>
from numpy.core._multiarray_umath import (
ImportError: DLL load failed: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Anaconda3\lib\pkgutil.py", line 493, in find_loader
spec = importlib.util.find_spec(fullname)
File "C:\Anaconda3\lib\importlib\util.py", line 94, in find_spec
parent = __import__(parent_name, fromlist=['__path__'])
File "C:\Anaconda3\lib\site-packages\numpy\__init__.py", line 142, in <module>
from . import core
File "C:\Anaconda3\lib\site-packages\numpy\core\__init__.py", line 54, in <module>
raise ImportError(msg)
ImportError:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy c-extensions failed.
- Try uninstalling and reinstalling numpy.
- If you have already done that, then:`enter code here`
1. Check that you expected to use Python3.7 from "C:\Anaconda3\python.exe",`enter code here`
and that you have no directories in your PATH or PYTHONPATH that can
interfere with the Python and numpy version "1.18.1" you're trying to use.
2. If (1) looks fine, you can open a new issue at
https://github.com/numpy/numpy/issues. Please include details on:
- how you installed Python
- how you installed numpy
- your operating system
- whether or not you have multiple versions of Python installed
- if you built from source, your compiler versions and ideally a build log
- If you're working with a numpy git repository, try `git clean -xdf`
(removes all files not under version control) and rebuild numpy.
Note: this error has many possible causes, so please don't comment on
an existing issue about this - open a new one instead.
Original error was: DLL load failed: The specified module could not be found.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Anaconda3\lib\site-packages\PyInstaller\utils\hooks\__init__.py", line 320, in get_module_file_attribute
loader = pkgutil.find_loader(package)
File "C:\Anaconda3\lib\pkgutil.py", line 499, in find_loader
raise ImportError(msg.format(fullname, type(ex), ex)) from ex
ImportError: Error while finding loader for 'numpy.core' (<class 'ImportError'>:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy c-extensions failed.
- Try uninstalling and reinstalling numpy.
- If you have already done that, then:
1. Check that you expected to use Python3.7 from "C:\Anaconda3\python.exe",
and that you have no directories in your PATH or PYTHONPATH that can
interfere with the Python and numpy version "1.18.1" you're trying to use.
2. If (1) looks fine, you can open a new issue at
https://github.com/numpy/numpy/issues. Please include details on:
- how you installed Python
- how you installed numpy
- your operating system
- whether or not you have multiple versions of Python installed
- if you built from source, your compiler versions and ideally a build log
- If you're working with a numpy git repository, try `git clean -xdf`
(removes all files not under version control) and rebuild numpy.
Note: this error has many possible causes, so please don't comment on
an existing issue about this - open a new one instead.
Original error was: DLL load failed: The specified module could not be found.
)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\User\Desktop\auto-py-to-exe-master\auto_py_to_exe\packaging.py", line 131, in package
run_pyinstaller()
File "C:\Anaconda3\lib\site-packages\PyInstaller\__main__.py", line 114, in run
run_build(pyi_config, spec_file, **vars(args))
File "C:\Anaconda3\lib\site-packages\PyInstaller\__main__.py", line 65, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "C:\Anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 734, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "C:\Anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 681, in build
exec(code, spec_namespace)
File "C:\Users\User\AppData\Local\Temp\tmp30rpmpfm\auxiliar.spec", line 17, in <module>
noarchive=False)
File "C:\Anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 244, in __init__
self.__postinit__()
File "C:\Anaconda3\lib\site-packages\PyInstaller\building\datastruct.py", line 160, in __postinit__
self.assemble()
File "C:\Anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 422, in assemble
self.graph.process_post_graph_hooks()
File "C:\Anaconda3\lib\site-packages\PyInstaller\depend\analysis.py", line 311, in process_post_graph_hooks
module_hook.post_graph()
File "C:\Anaconda3\lib\site-packages\PyInstaller\depend\imphook.py", line 417, in post_graph
self._load_hook_module()
File "C:\Anaconda3\lib\site-packages\PyInstaller\depend\imphook.py", line 384, in _load_hook_module
self.hook_module_name, self.hook_filename)
File "C:\Anaconda3\lib\site-packages\PyInstaller\compat.py", line 797, in importlib_load_source
return mod_loader.load_module()
File "<frozen importlib._bootstrap_external>", line 407, in _check_name_wrapper
File "<frozen importlib._bootstrap_external>", line 907, in load_module
File "<frozen importlib._bootstrap_external>", line 732, in load_module
File "<frozen importlib._bootstrap>", line 265, in _load_module_shim
File "<frozen importlib._bootstrap>", line 696, in _load
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Anaconda3\lib\site-packages\PyInstaller\hooks\hook-numpy.core.py", line 29, in <module>
pkg_base, pkg_dir = get_package_paths('numpy.core')
File "C:\Anaconda3\lib\site-packages\PyInstaller\utils\hooks\__init__.py", line 537, in get_package_paths
file_attr = get_module_file_attribute(package)
File "C:\Anaconda3\lib\site-packages\PyInstaller\utils\hooks\__init__.py", line 339, in get_module_file_attribute
raise ImportError
ImportError
Project output will not be moved to output folder
Complete.
Convert .py to .exe
Install auto-py-to-exe library
pip install auto-py-to-exe
Run the following command to convert .py to .exe
python -m auto_py_to_exe first.py
Follow the instructions
code:
import gym
env = gym.make('Breakout-v0')
I get an error:
Traceback (most recent call last):
File "C:/Users/danie/Downloads/Programming/Python/Programming/Pycharm/app.py", line 40, in
gym.make("Breakout-v0")
File "C:\Users\danie\AppData\Local\Programs\Python\Python37\lib\site-packages\gym\envs\registration.py", line 156, in make
return registry.make(id, **kwargs)
File "C:\Users\danie\AppData\Local\Programs\Python\Python37\lib\site-packages\gym\envs\registration.py", line 101, in make
env = spec.make(**kwargs)
File "C:\Users\danie\AppData\Local\Programs\Python\Python37\lib\site-packages\gym\envs\registration.py", line 72, in make
cls = load(self.entry_point)
File "C:\Users\danie\AppData\Local\Programs\Python\Python37\lib\site-packages\gym\envs\registration.py", line 17, in load
mod = importlib.import_module(mod_name)
File "C:\Users\danie\AppData\Local\Programs\Python\Python37\lib\importlib_init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1006, in _gcd_import
File "", line 983, in _find_and_load
File "", line 967, in find_and_load_unlocked
File "", line 677, in load_unlocked
File "", line 728, in exec_module
File "", line 219, in call_with_frames_removed
File "C:\Users\danie\AppData\Local\Programs\Python\Python37\lib\site-packages\gym\envs\atari_init.py", line 1, in
from gym.envs.atari.atari_env import AtariEnv
File "C:\Users\danie\AppData\Local\Programs\Python\Python37\lib\site-packages\gym\envs\atari\atari_env.py", line 9, in
import atari_py
File "C:\Users\danie\AppData\Local\Programs\Python\Python37\lib\site-packages\atari_py_init.py", line 1, in
from .ale_python_interface import *
File "C:\Users\danie\AppData\Local\Programs\Python\Python37\lib\site-packages\atari_py\ale_python_interface.py", line 18, in
'ale_interface/build/ale_c.dll'))
File "C:\Users\danie\AppData\Local\Programs\Python\Python37\lib\ctypes_init.py", line 434, in LoadLibrary
return self.dlltype(name)
File "C:\Users\danie\AppData\Local\Programs\Python\Python37\lib\ctypes_init.py", line 356, in init
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found
I was finally able to get around this problem with help from the following website: https://towardsdatascience.com/how-to-install-openai-gym-in-a-windows-environment-338969e24d30.
There were basically 3 things I had to do: 1) install Microsoft Visual C++ Build Tools, 2) install this specific verion of Atari https://github.com/Kojoley/atari-py.git, 3) Install Xming. Good luck to all Windows users :) This took me around 3 days to figure out.
I have tried to make it work with python 3.8 and 3.9 on Windows 10. Installing Python 3.7 and using it as the Python Interpreter on PyCharm resolved the issue. I have searched for the missing file while having 3.8 + version of Python and it did not exist at all. Atari-py is supported only for Python 3.7 (https://github.com/openai/atari-py) so having a higher version of that would not work. It is a bad idea to download files from unlicensed places so I advise you to install the supported version of Python (3.5, 3.6, and 3.7). Even though gym can work on 3.9 the atari version will not. I did not need anything else installed (although I may have Microsoft Visual C++ Build Tools, but I deff did not need Xming), just import gym 0.18.0, pyglet 1.5.0, atari -py 0.2.6
Welcome to SO. If you trace the exception trace you see that a shared object loading function is called in ctypes' init.py file aliased as dlopen. On Windows, this correponds to WINAPI's LoadLibrary method. LoadLibrary is trying to load ale_c.dll. ALE is 'arcade learning environment'.
Search your computer for ale_c.dll or libale_c.dll
If you have ale_c.dll (most likely you are on Windows), refer to this answer to see how DLL's loaded with ctypes are basically LoadLibrary calls as I mentioned. It mentions all the stuff about DLL loading order etc. but, if you need a quick way around this, copy your dll under system32 folder.
I had similar issue with Atari-Pacman. It is resolved by downloading atari_py-1.2.1-cp37-cp37m-win_amd64 which is for 64-bit Python 3.7, and installing it by using pip.
I just installed Python 3.7 and Fabric.
It works perfectly on my laptop, but not on my desktop.
The error :
Traceback (most recent call last):
File "C:\Program Files (x86)\Python37-32\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Program Files (x86)\Python37-32\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\python_project\myProject\env\Scripts\fab.exe\__main__.py", line 9, in <module>
File "c:\python_project\myProject\env\lib\site-packages\invoke\program.py", line 352, in run
self.parse_collection()
File "c:\python_project\myProject\env\lib\site-packages\invoke\program.py", line 444, in parse_collection
self.load_collection()
File "c:\python_project\myProject\env\lib\site-packages\fabric\main.py", line 82, in load_collection
super(Fab, self).load_collection()
File "c:\python_project\myProject\env\lib\site-packages\invoke\program.py", line 661, in load_collection
module, parent = loader.load(coll_name)
File "c:\python_project\myProject\env\lib\site-packages\invoke\loader.py", line 76, in load
module = imp.load_module(name, fd, path, desc)
File "C:\Program Files (x86)\Python37-32\lib\imp.py", line 235, in load_module
return load_source(name, filename, file)
File "C:\Program Files (x86)\Python37-32\lib\imp.py", line 172, in load_source
module = _load(spec)
File "<frozen importlib._bootstrap>", line 696, in _load
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\python_project\myProject\fabfile.py", line 2, in <module>
from fabric.api import task, run, env, settings, hide
ModuleNotFoundError: No module named 'fabric.api'
But Fabric seem to be installed ?
C:\Users\MyUser>pip install fabric
Requirement already satisfied: fabric in c:\program files (x86)\python37 32\lib\site-packages (2.4.0)
C:\Users\MyUser>pip show fabric
Name: fabric
Version: 2.4.0
Summary: High level SSH command execution
Home-page: http://fabfile.org
Author: Jeff Forcier
Author-email: jeff#bitprophet.org
License: BSD
Location: c:\program files (x86)\python37-32\lib\site-packages
Requires: paramiko, cryptography, invoke
Required-by:
However "fabric" didn't appear in the list when I do the following in idle (just Fabfile) :
>>> import pkgutil
>>> [name for _, name, _ in pkgutil.iter_modules()]
['fabfile', '_asyncio', '_bz2', ... 'enum', 'filecmp', 'fileinput', ...]
I also tried to uninstall/reinstall fabric, but it's still failing.
Do you have any idea why I cannot import fabric.api ?
Update :
I also created a virtual environment :
py -3 -m venv env
code .
Selected Python interpreter "venv" in Visual Studio code then :
python -m pip install fabric
But i'm still facing the same error :-/
Well after few research I finally found a workaround by using fabric3 (a fork of Fabric, compatible python 3).
pip uninstall fabric
pip install fabric3
Link : https://pypi.org/project/Fabric3/
I see you have already installed fabric 2.4.0 which is great! Since you are using the fabric 2.4.0 you can't use from fabric.api import taks. fabric.api could be used if you use fabric1xx
If you want to import connection and task from fabric2.4.0 you have to do it like this
from fabric import Connection as connection, task
#task
def deploy(ctx):
with connection(host=host, user=user) as c:
c.run('ls -la')
Note: fabric 3 is not an official fork. I advise you to use fabric2.4.0