1
At first I uploaded the Run.exe file packaged on Windows directly to Linux and thought it could be used directly. But./run after the error. Baidu later know that theprogram on Windows can not run on Linux
Linux under the executable can be a suffix does not have a relationship, only with permissions, relying on the permissions of the file itself. Want to execute chmod 755 filename Change file permissions
Windows and Linux binaries can not be compatible, landlord check bar, you can not run Windows under Linux programs. Be sure to run under Linux and need to install wine
Linux default support ELF format binary files, Windows PE format can not run.
2 python after packaging with Pyinstaller, run the program error "pkg_resources. Distributionnotfound "solution
Pkg_resources. Distributionnotfound:the "Apscheduler" distribution is not found ....
Here obviously has packed the EXE file, also did not error. But when running the EXE, but the interface pops up and flashed through.
After reviewing the official documents of Pyinstaller , we found a solution .
Create a hook-ctypes.macholib.py file under the target file directory:
The contents are as follows:
#-*-Coding:utf-8-*-
From PyInstaller.utils.hooks import Copy_metadata
Datas = Copy_metadata (' Apscheduler ')
Then, when packing, add a--additional-hooks-dir=, as follows:
Pyinstaller-f yourfile.py--additional-hooks-dir=
After this modification, the package of EXE files will be able to use the normal.
3 APScheduler:LookupError:No Trigger by the name "interval" was found
Environment
python:2.6.6
pyinstaller:2.1
Apscheduler: It started with 3.0.1, then 3.0.5 .
Question One
Problem description
A Python program (python2.7)that was previously developed on another machine, running the Times wrong on a new machine
" interval " was found
Program code
ImportOS, time fromDatetimeImportdatetime fromApscheduler.schedulers.backgroundImportBackgroundschedulerdefmyjob ():Print('myjob:%s'%DateTime.Now ()) Time.sleep (5)if __name__=='__main__': Scheduler=Backgroundscheduler () scheduler.add_job (Myjob,'interval', Seconds=1) Scheduler.start ()Try: whileTrue:time.sleep (5) except(Keyboardinterrupt, Systemexit): Scheduler.shutdown ()
Reason
is due to the low version of Setuptools causing
Solutions
sudo pip install----ignore-installed Apscheduler
Then run the above Python code again to solve the problem.
Question Two
Problem description
When the first problem is resolved, an error is generated when you run an executable file that uses Pyinstaller packaging
Traceback (most recent): File"<string>", line 11,inch<module>File". ../out00-pyz.pyz/apscheduler.schedulers.base", line 330,inchadd_job File". ../out00-pyz.pyz/apscheduler.schedulers.base", Line 782,inch_create_trigger File". ../out00-pyz.pyz/apscheduler.schedulers.base", line 766,inch_create_plugin_instancelookuperror:no trigger by the name"interval"was found
Reason
It feels as if Pyinstaller was using the wrong version of Apschedulerwhen it was packaged. (not sure)???
Solutions
Do not use "' Interval ', Seconds=1" in the Add_job method to do trigger, but first create a Intervaltrigger object, and then Use this object when Add_job, namely:
Modify the original code
' interval ', Seconds=1)
For
Trigger = Intervaltrigger (Seconds=1) scheduler.add_job (myjob, Trigger)
The complete code is as follows
defmyjob ():Print('myjob:%s'%DateTime.Now ()) Time.sleep (5)if __name__=='__main__': Scheduler=Backgroundscheduler () trigger= Intervaltrigger (Seconds=1) Scheduler.add_job (myjob, Trigger) Scheduler.start ()Try: whileTrue:time.sleep (5) except(Keyboardinterrupt, Systemexit): Scheduler.shutdown ()
Then re-package with Pyinstaller, at this time to run the executable file will not be an error.
Focus: Because of the use of Intervaltrigger, so need to import from the package, and then I find such a post http://blog.csdn.net/mx472756841/article/details/51751616
Use the following code in this
#Sample Code fromApscheduler.triggers.intervalImportIngervaltrigger#using string MethodsScheduler.add_job (Interval_tick,'interval', seconds=4,minutes=2, start_date=datetime.now () +dt.timedelta (seconds=120), end_date=datetime.now () +dt.timedelta (seconds=360)) #use Intervaltrigger to specify time to runTrigger = Intervaltrigger (seconds=60, start_date=datetime.now () +dt.timedelta (seconds=60), end_date=datetime.now () + Dt.timedelta (seconds=120) ) Scheduler.add_job (Date_tick, Trigger)
But his import here is wrong. I found a half-day, and later used in Python's own user graphical interface in the import Apschedluer after using DIR () step-by-step to find the correct name, and then run through.
4 you need to connect to the local database (MySQL on XAMPP) after packaging the executable file
At the same time is also to solve Navicat error : 1130-host. is not allowed to connect to this MYSQL server,mysql does not allow remote access from The method (http://www.cnblogs.com/shyy/archive/2012/03/30/2453034.html) to ask.
Https://jingyan.baidu.com/article/d169e186467a44436611d8b1.html
You can enter the shell after the operation (if the host is the% number, then all hosts can log on, including the remote host .)
Musql-uroot
Select Host,password,user,from User;
Update user Set host = "%" where host = "127.0.0.1"
Related Documents (http://blog.csdn.net/xiaomengh/article/details/48706149)
5 greenlet.h:8:20: Fatal error: Python.h: No file or directory
The workaround is to install Python-dev, which is the Python header file and the static library package:
sudo apt-get install Python-dev
But it's still not working, TODO.
Todo
Python packaged as an executable file