2017-02-17 125 views
3

我试图将.py脚本转换为.exeCXfreeze - 需要appdirs包

Cxfreeze成功编译exe文件。然而,当我运行exe文件时,它抛出这个错误:

ImportError: The 'appdirs' package is required; normally this is bundled with th 
is package so if you get this warning, consult the packager of your distribution 

这里是我的setup.py

从cx_Freeze进口设置,可执行

setup(
    name = "dbx_sharelink" , 
    version = "0.1" , 
    description = " " , 
    executables = [Executable("dbx_sharelink.py")] , 
) 

源码Python脚本

import sys 
import dropbox 
import pandas as pd 
import sys 
import os 

dbx = dropbox.Dropbox('xxxxxxxxxxxxxxxxx') 

def getSharedLink(full_path): 
    try: 
     link = dbx.sharing_create_shared_link(full_path).url 
    except dropbox.exceptions.ApiError as err: 
     print('*** API error', err) 
     return None 
    return link 


print(sys.argv[1]) 
link = getSharedLink("/A_DATA/data") 

df = pd.DataFrame([{'link':link}]) 
df.to_clipboard(index=False,header=False) 


os.system("pause") 

如何解决此错误?

+1

你能分享你试图冻结的Python脚本吗? –

+0

我现在将源代码添加到我的问题中。 – jortiexx

回答

0

我有同样的问题.. 添加选项参数的setup.py文件是这样的:

setup (name="MyAPP", 
     version="0.1", 
     description = "My GUI application!", 
     options = {'build_exe': {'packages':packages}}, 
     . 
     . 
     .) 

套餐应该在设置之前):

packages = ['pkg_resources._vendor'] 

(你可以,如果你有这样一个类似的问题,增加更多的包..)

您可以了解更多关于此处的选项:http://cx-freeze.readthedocs.io/en/latest/distutils.html#build-exe

这解决了这个问题对我来说!


0

尝试升级到34.4.1 setuptools的,这个工作对我来说

+0

这对于Linux上的python 3.6.1并不适用,setuptools不依赖于appdirs。 cx_freeze也不会将appdirs作为pip3的依赖项安装。 – Kevin