cx_Freeze - The appdirs package is required

匿名 (未验证) 提交于 2019-12-03 01:33:01

问题:

I`m trying to convert a .py script to an .exe

cx_Freeze compiles the exe succesfully. However when I run the exe file it throws this error:

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

Here is my setup.py

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

Source code Python script

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") 

How to resolve this error?

回答1:

I was having the same problem.. Add options parameter to the setup.py file like this:

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

under packages put(packages should come before the setup):

packages = ['pkg_resources._vendor'] 

(you can add more packages if you have similar problems like this one..)

you can read more on the options here: http://cx-freeze.readthedocs.io/en/latest/distutils.html#build-exe

This solved the problem for me!




回答2:

I had the same problem. Just add the packages to the options

additional_mods = ['appdirs', 'packaging.version'] additional_packages = ['scipy', 'numpy', 'appdirs', 'packaging']  options = {         'build_exe': {                       'packages': additional_packages,                       'includes': additional_mods,         } 


回答3:

Trying upgrading to setuptools 34.4.1, this worked for me



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!