Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cx_Freeze - The appdirs package is required

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?

like image 444
jortiexx Avatar asked Feb 17 '17 11:02

jortiexx


2 Answers

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!


like image 177
Marom Avatar answered Oct 09 '22 22:10

Marom


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,
        }
like image 26
DMST Avatar answered Oct 09 '22 23:10

DMST