os.popen doesn't work after compiler with pyinstaller - python-3.x

The following line is what I'm using to open the file in python, and this action called by a button(tkinter).
os.popen(r'"C:\Program Files (x86)\Foxit Software\Foxit Reader\FoxitReader.exe" %s' %filename)
My development environment is Python3.7 + spyder 3.3.1 + windows 7 + latest version pyinstaller.
The issue is that this line can work well in spyder, but after compiler.
pyinstaller -F -w --onefile --icon=icon.ico ./DMS.py
I used this command to compile the Python script. When I click the button which I mentioned above, there is no any action be executed and no any error message pop up. I'm sure the application didn't hang on or crush.
When I try the following command to check what message on console.
pyinstaller -F DMS.py
The miracle happen, the PDF file can be opened without problem, and there is no any error message show on the console.
Does anyone know what things happen? and any suggestion for this case if show the console front of end user is not an option.
Many thanks.

Related

Executable not runing pyinstaller

My computer is runing Linux mint 20 with python 3.8
Created an executable file with PyInstaller with the following comand being in the correct PATH folder:
`python3 -m PyInstaller [filename.py] `
I had to use that command because when i tried:
`pyinstaller [filename.py]`
Got an error message stating order not found.
However it does work, it creates the excecutable but once it is created i double click it or try to open it and doesn't run.
When i run the python file with the terminal it works perfect.
I need to know what to doto get it working.
Thanks

Running pyinstaller in a command prompt returns "failed to create process"

I am trying to convert my python file into a .exe, and I found out about pyinstaller. I ran in the command prompt:pip install pyinstaller. After a few seconds, the last line said something like "pyinstaller was successfully installed" then when I am running just "pyinstaller" in the command prompt, it prints "failed to create process.". I tried running it in the directory with the scripts, I tried doing "pyinstaller myprogram.py" in the directory of my program. I even went to windows 10, "Advanced system settings" and added the directory of my python scripts, but it always returns this "failed to create process." I looked at other questions in stackoverflow. I even looked at the first lines of scripts of the pyinstaller but they already had quotes, so I do not know what is wrong.
Any reply would be appreciated.
It seems that this is a known issue with cx_Freeze which has been resolved in the source. It will be fixed in the new release (5.1.1)
I had the same issue so I checked the file
C:\Python27\Scripts\pyinstaller-script.py
and there was an old python path which when I installed python installer
C:\Python27\python.exe
But later I renamed python.exe --> python2.exe, so I just changed the path
C:\Python27\python.exe --> C:\Python27\python2.exe
in file
C:\Python27\Scripts\pyinstaller-script.py
and it worked perfectly.I would also suggest check you environemnt variables too carefully.

execute to exe. successful by pyinstaller, but the exe. is not work. How can I debug it

It's work on Spyder (Anaconda3) and execute script to exe by pyinstaller without any errors, but nothing happens when I double click exe (also try cx_freeze, but still not work either).
How can I debug it? Appreciate for your help.
import os,shutil
cur_path=os.path.dirname(__file__)
sample_tree=os.walk(cur_path)
for dirname,subdir,files in sample_tree:
allfiles=[]
basename=os.path.basename(dirname)
for file in files:
ext=file.split('.')[-1]
if ext=="csv":#讀取.csv to allfiles
allfiles.append(file)
elif ext=='log':#讀取.log to allfiles
allfiles.append(file)
for file in allfiles:#Copy csv and log of sample_tree to destfolder
destfile = cur_path
srcfile=dirname + "/" + file
shutil.move(srcfile,destfile)
p.s. python 3.6/pyinstaller 3.3/Win 10
Debugging is s simple enough process.
In cx_Freeze you can find any errors by doing the following:
Before building ensure your script works correctly.
When building from a setup script see If any errors or warnings appear while it turns into an application. Do not worry if you get warnings you get these even when the application works correctly just ensure you know about them since they may give you a clue why it is not working.
When you application has been built it run it from command line. This final step will show up any errors.
Next you need to configure you setup script accordingly and recompile it and finally run through the process again to see if you have fixed the problem.
For Pyinstaller follow the same process.
In both modules the best debugging method is to run it from command line.
You can check your application by opening a new terminal window where the application is located and running it
For Linux and CMD (Windows):
yourappname
and for PowerShell:
./yourappname

Pycharm tensorflow ImportError but works fine with Terminal

I made a virtualenv with tensorflow installed and I changed Python interpreter set to the location where the virtualenv is located at. When I ran the program, it gives the error:
ImportError: libcudnn.so.5: cannot open shared object file: No such file or directory
I have the following lines written in my .bashrc file
export CUDA_HOME=/usr/local/cuda-8.0
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:$LD_LIBRARY_PATH
export PATH=${CUDA_HOME}/bin:${PATH}
Also, I found the libcudnn.so.5 file in the following path:
/usr/local/cuda-8.0/lib64
I encountered this error before I opened PyCharm and I did manage to install the correct cudnn version. The problem is, I can use
$ source [virtualenv_path]
to active the virtualenv and run python in terminal and everything works fine, no errors shown. The program also runs without error in Pycharm's terminal but it just gives me the above error whenever I click the run button. Could there still be something wrong with the environment variable? How do I fix it?
Unfortunately in pycharm you have to set CUDA_HOME and LD_LIBRARY_PATH inside the IDE. To do that go to the Run menu->edit configurations then choose your project. Then you click on the Environment Variables and add an entry for CUDA_HOME and LD_LIBRARY_PATH. When you have done that you can run directly from inside pycharm. I would also recommend setting the defaults to have these paths as well, so you don't have to do this for every project. Also it wouldn't hurt to make sure you have the interpreter from source [virtualenv_path] set while you are on this setting page. Let me know if you have trouble finding where to do this.
I've read this other Stackoverflow post: Pycharm environment different than command line, and it seems that the problem is that openning PyCharm in the normal way won't preserve the bash environment. The solution is to open PyCharm from the command line and everything works now. All you need to do is to open PyCharm using charm and everything works fine now.
I have searched a lot, but I didn't find the right solution for this question anywhere. I found the solution with my friends and I would like to share with you also.
If your Tensorflow works in terminal properly but doesn't work in Pycharm you have two solutions:
1- Open Pycharm from Terminal. For me:
pycharm-community
2- If you are using Unity, you need to edit .profile, because Pycharm doesn't preserve .bashrc: So, open a terminal and type:
gedit .profile
Then, add the following codes at the end of the opened file:
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
Save and exit. Now, you can work with Tensorflow in Pycharm without the necessity of opening the Pycharm form terminal.

cx_freeze executable runs from cmd but not on click

After dealing with all .egg issues with cx_freeze, I'm having issues running the .exe on click or from .bat. If I run the .exe from cmd, it runs perfectly. But if I click on the .exe, I get a popup list of errors that goes off the page.
I've tried changing the base=None and base=Win32GUI to no avail.
I'm running python 3.4 from and Anaconda environment. The errors make it look like on running, the .exe is looking in the normal python path, but there are references the the correct python path as well.
Any experiences with this?
Error from clicking. This goes off the screen so I can't see the final error:
error

Resources