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?
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!
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,
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With