PyInstaller Executable File: ModuleNotFoundError - Pandas - pandas

Background: I have a .py script which uses c.10 libraries/dependencies (e.g., pandas numpy json) and the script also relies on a .ini file, which it looks for in the same dir as it is located.I want to add this .py file to Windows Scheduler, but before I can, I must make the file executable.
Issue: I used PyInstaller to create an executable file. I also added -- onefile and -w when creating the .exe file. My issue is that when I attempt to run the main.exe (either by double-clicking or through cmd) I get the following Unhandled exception in script -
Help: I am trying to understand how this is happening, especially as my understanding of PyInstaller is that it would create an executable file, which would inc. everything the script needs to run (Note: I have double checked that the .py contains import pandas etc.
Can someone explain to me how I would troubleshoot this and/or if there are any key steps I may have obviously missed, which might be causing this?

Try using this commandline for compiling your python file, pyinstaller.exe --onefile --noconsole --hidden-import pandas {Your_FILE_NAME}.py

Related

py2exe setup script work only if placed under the same path of the target script

I created the setup.py script to create the exe (where the freeze or setup functions are called with a target script 'target.py'), then I invoke the script as 'python setup.py py2exe'.
However I discovered that the executable is created fine as far as this setup.py script is in the same location of the target.py script. If The two script are not in the same location the created executable does not work because not all parts of the code are included.
I am missing something about a rule of setup.py and target.py script ?
I have verified I am passing correctly the target.py location to the setup.py.
Important, the exe creation does not fail or whatever, simply the created exe is not functional since it is missing something.
Moreover I have an old code (py2exe in py2.7) where the setup and target scripts are not in the smae location and it works.
I expected that the relative position of the target.py script with respect to the setup.py script should not influence the outcome (exe). What I acutally get is a different result.
I have an old code where the two scripts are not in under the same path and it works (with an old py2exe and py2.7)
The documentation is not explicitly mentioning something about this.

one file fails to execute pyinstaller

I have been using pyisnataller to create executable applications of my python 3.6.5 scripts. The scripts are GUI interfaces. I have used a recipe from a previous stackoverflow post: link
It has been effective but am running into a slight snafu trying one file a simple GUI.
Why does the executable fail to run? The temporary folder created has the two files added within about.spec?
Any help would be appreciated!
I would have placed the code, and the spec file here but stackoverflow didnt seem to perform the formatting well enough to send the message. I tried backticks four spaces, a missing line followed by eight space, and
Yes, this is an ill posed question. So, turns out the pyinstaller creates a warn_yourscript_.txt file and the post warnings in the creation of the executable. The file is located in the working directory/build/yourscript/warn_yourscript_.txt. Having looked into the file, there was a warning about not being able to load or missing the TKinter module. The myscript.py was running smoothly under python 3.6.5, but I may have started my script from a starter on the internet and may have been from an earlier python. I have several pythons loaded on my machine, python could find it but pyinstaller could not? I changed out myscript to reflect earlier success with tkinter instead.

Tensorflow(GPU) in sublime text 3

I tried to install tensorflow and finally got there.
I got an error:
ImportError: libcudnn.Version: cannot open shared object file: No such
file or directory
while I was installing but I could handle it. I think it works fine in terminal.
However, the problem is when I tried to import tensorflow in sublime text, it spits the same error.
ImportError: libcudnn.so.6: cannot open shared object file: No such
file or directory
Cause I changed the build system path to /home/username/.conda/envs/tensorflow/bin, I can't understand why I get this error here.
Is there anyone who can help me?
As it is working from terminal I think everything like cuda, cudnn and GPU drivers are setup properly and the export path is added to the .bashrc (~/.bashrc) file. That's why running from terminal works. As adding the export information to only .bashrc file will make it work on terminal but won't help for other programs like sublime.
So, I suggest, you take the export information from .bashrc file and add it to /etc/environment file. You need to log out from current user and login again so environment variables changes take place. The export information on .bashrc file should look something like this.
export PATH=/usr/local/cuda-8.0/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64\${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

Embedded Python 3 not creating .pyc files when using importlib

I'm trying to embed a Python 3 interpreter in an Objective C Cocoa app on a Mac, following instructions in this answer (which extends this article) and building Python and PyObjC by hand.
I'd like to be able to run Python code as plugins. I specifically don't want to rely on the stock Apple Python (v2.7). I have most of it working but can't seem to reliably load the plugin scripts. It looks like the embedded Python interpreter is unable to create the __pycache__/*.pyc files. This may be a symptom, or a cause. If I import the plugin file manually from the Python3 REPL (via import or the imp or importlib modules) the .pyc is generated and the plugin then loads correctly. If I don't do this manually the .pyc is not created and I receive a ValueError "Unmarshallable object".
I've tried loosening permissions on the script directory to no avail. The cache_tag looks OK, both from the REPL and from within the bouncer script:
>>> sys.implementation.cache_tag
'cpython-35'
py_compile raises a Cocoa exception if I try and compile the plugin file manually (I'm still digging into that).
I'm using the following:
OS X 10.11.5 (El Capitan)
XCode 7.2.1
Python v3.5.2
PyObjC v3.11
I had to make a couple of necessary tweaks to the process outlined in the linked SO answer:
Compiling Python 3 required Homebrew versions of OpenSSL and zlib, and appropriate LDFLAGS and CPPFLAGS:
export CPPFLAGS="-I$(brew --prefix openssl)/include -I$(brew --prefix zlib)/include"
export LDFLAGS="-L$(brew --prefix openssl)/lib -L$(brew --prefix zlib)/lib"
I also ensure pip is installed OK when configuring Python to build:
./configure --prefix="/path/to/python/devbuild/python3.5.2" --with-ensurepip=install
There is a fork of the original article source (which uses the stock Python2) that works fine here, so I suspect I'm not too far off the mark. Any idea what I've missed? Do I need to sign, or otherwise give permission to, the embedded Python? Are there complilation/configuration options I've neglected to set?
TIA
Typical. It's always the last thing you try, isn't it? Adding the directory containing the plugin scripts to sys.path seems to do the trick, although I'm not sure why importlib needs this (I thought the point was to allow you to circumvent the normal import mechanism). Perhaps it's to do with the way the default importlib.machinery.SourceFileLoader is implemented?
Something like:
sys.path.append(os.path.abspath("/path/to/plugin/scripts"))
makes the "Unmarshallable object" problem go away. The cache directory and .pyc files are created correctly.

Jython ImportError when embedding into Java on 'xml.dom.minidom'

I have a python script which is processing XML using xml.dom.minidom.
When I executed it with Jython by command line (jython myfile.py), everything was fine.
But when I tried to do the same thing embedding it into a java application, (I mean reading it as an java string then passing this string for evaluation) I got:
import xml.dom.minidom
ImportError: No module named xml
Which is driving me crazy. I tried to use different jython version (2.2, 2.5), to clear the cache, but nothing works!
Jython's Documentation tells me that we can use this module without any particular remarks.
Some people had the same problem on the internet but never got any replies. Except this:
here but still nothing work. I think I have the correct values in my jython registry, because it's working using the command line! It's just the embedding which fails everything.
I'm using a full install of Jython.
Why so much trouble, so?
Thanks in advance.
i've never done this before, but are you trying to embed jython like they did here or here? do you know where you got the jython.jar in your java classpath from? if you know where your jython module is located on disc then you might be able to just add that path as they did at the bottom of this page. To find the location of your module, load up jython and look in sys.path for a path that ends in Lib. that location should have a directory named xml (the xml package) which contains a directory named dom (the dom package), which contains a file minidom.py (the minidom module).
The xml module (jython) isn't on the the python-path of your embedded jython.
This may help:
use a jython-jar which contains the Lib (and all the Batteries :-)
put the Libs on the classpath of your java app
to help debug:
log "sys.path" in your embedded jython