程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Run flash back after Python is packaged in Windows: other referenced software packages such as xlrd and xlwt are not packaged together

編輯:Python

         Recently, there is something that needs to be handled to generate dozens of data excel form , At first I thought of using c++ To write code for processing , It turned out c++ Yes excel The use of forms is not very friendly , So I will study temporarily python, Learn by doing through online examples and code .

         Finally in their own compiler pycharm After the problem is solved successfully , Others should also use , But other people's computers don't python Environmental Science , Just pack it when you think about it , There's a problem , It was packed in windows Always pack successfully on ( Packaging does not check for problems ), But there is something wrong with the operation , The reason is to use to process excel Of xlrd and xlwt Not packed together .

         Because the code starts with mac Written on the computer , Then copy it to windows Packed in the computer , It's packed with pyinstaller, You can search how to download and use this by yourself , I'm also in cmd Download in , Also in the pycharm Download the software package in , In this way pycharm Terminals and cmd All of them can be packed .

Then pack what everyone knows , I won't repeat it , The key is that there is a problem , Do you have any problems with the environment settings when you create a new project , I am setting Virtualenv Environment into the project , That's why it's in the catalog venv, The package I downloaded xlrd and xlwt Also in the project . Pictured :

The interpreter is not the same , The one above is set in the project , The next one is set to python in , Pictured :

 

So it may lead to my python There is no such bag !!

So where to find us python Where to see python Is there any package we downloaded in the environment

        stay win+R open cmd, Then input where python There will be an address ( As I am :C:\Users\xx\AppData\Local\Programs\Python\Python310\), Then find the... Under this directory C:\Users\xx\AppData\Local\Programs\Python\Python310\Lib\site-packages, Go to this folder to see if you have any packages you need to import , I recommend that you do not change the environment when setting the project , I just changed it to cause this site-packages There is no package that I need to import .

        terms of settlement Is that you put , Like the one in the above figure site-packages Replace the folder of with python The folder in the , Of course, you can also copy only part of the contents of the folder ( Make sure to copy all of ), Packaging again can solve this problem .

        When the package succeeds, my test.spec Nothing has changed in the file , So it shouldn't be about this file , But later I need to use external data sources excel file , I still made changes in this file , You can package the external data source files together , Here's the picture :

          You must pay attention to packing at this time , To use pyinstaller xxx.spec , As in my picture ( there "." Represents the folder , You can also set other paths ), At this time you go dist You can see that this file is packed together , As for how this came from , You pack it for one time pyinstaller xxx.py Just pack it once .

         In normal use, we don't need to care spec Of documents , However, the following situations need to be modified spec file :

  • You need to package the resource file ;
  • need include some PyInstaller Unknown Library ;
  • Add... To the executable run-time Options ;
  • Multi program packaging .

         Later, this small program will be in mac When packaging on , Other problems have been found , After packing, I kept saying that I couldn't be found xls file , But the same code is windows But I can run normally , This will be written in another article of mine .


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved