FileNotFoundError: ... build\\<dependency package>.libs when using setup.py

Hi,

I have been trying to export the latest version of my Panda3D application (I have done it in the past following the ‘Distributing Panda3D Applications’ in the manual) but this time it has not been working. I have narrowed it down to break when I include two dependency packages, shapely and meshcut. Both of which have wheel files available on PyPi. But when I try to run the executable I get the following:

FileNotFoundError: [WinError 2] The system cannot find the file specified: 'C:\\Users\\Josh\\PycharmProjects\\CTCAM\\venv\\Scripts\\build\\shapely.libs'

I find it odd that it is searching directly in the build folder which only contains other folders. Also note that the wheel files are in the build\__whl_cache__\win_amd64_cp39 folder.

I have attached my setup.py, requirements, and the output when I have ran it to help.

setup.py file:

from setuptools import setup

setup(
    name="CTCAM",
    options = {
        'build_apps': {
            'gui_apps': {
                'CTCAM': 'CTCAM.py',
            },
            'platforms': ['win_amd64'],
            'log_filename': 'CTCAM APPDATA/output.log',
            'log_append': False,
            'include_patterns': [
                            'Setup/**',
                            'Tool Library/**'
            ],
            'use_optimized_wheels': False,
            'plugins': [
                'pandagl',
                'p3openal_audio',
                'p3assimp'
            ],
        }
    }
)

Also note: removing optimized wheels did not help.

requirements.txt file:

Panda3D~=1.10.13
numpy~=1.21.5
setuptools~=63.4.1

shapely~=2.0.1
meshcut~=0.3.0

When running ‘python setup.py build_apps’ I get the following error messages, but an executable is still built.

C:\Users\Josh\PycharmProjects\CTCAM\venv\Scripts>python setup.py build_apps
running build_apps
Building platforms: win_amd64
Gathering wheels for platform: win_amd64
Looking in indexes: https://pypi.org/simple, https://archive.panda3d.org/thirdparty
Collecting Panda3D~=1.10.13
  File was already downloaded c:\users\josh\pycharmprojects\ctcam\venv\scripts\build\__whl_cache__\win_amd64_cp39\panda3d-1.10.13-cp39-cp39-win_amd64.whl
Collecting numpy~=1.21.5
  File was already downloaded c:\users\josh\pycharmprojects\ctcam\venv\scripts\build\__whl_cache__\win_amd64_cp39\numpy-1.21.6-cp39-cp39-win_amd64.whl
Collecting setuptools~=63.4.1
  File was already downloaded c:\users\josh\pycharmprojects\ctcam\venv\scripts\build\__whl_cache__\win_amd64_cp39\setuptools-63.4.3-py3-none-any.whl
Collecting shapely~=2.0.1
  File was already downloaded c:\users\josh\pycharmprojects\ctcam\venv\scripts\build\__whl_cache__\win_amd64_cp39\shapely-2.0.1-cp39-cp39-win_amd64.whl
Collecting meshcut~=0.3.0
  File was already downloaded c:\users\josh\pycharmprojects\ctcam\venv\scripts\build\__whl_cache__\win_amd64_cp39\meshcut-0.3.0-py3-none-any.whl
Collecting numpy-stl
  File was already downloaded c:\users\josh\pycharmprojects\ctcam\venv\scripts\build\__whl_cache__\win_amd64_cp39\numpy_stl-3.0.1-py3-none-any.whl
Collecting scipy
  File was already downloaded c:\users\josh\pycharmprojects\ctcam\venv\scripts\build\__whl_cache__\win_amd64_cp39\scipy-1.10.1-cp39-cp39-win_amd64.whl
Collecting python-utils>=3.4.5
  File was already downloaded c:\users\josh\pycharmprojects\ctcam\venv\scripts\build\__whl_cache__\win_amd64_cp39\python_utils-3.5.2-py2.py3-none-any.whl
Successfully downloaded Panda3D numpy shapely meshcut numpy-stl scipy python-utils setuptools
Building runtime for platform: win_amd64
There are some missing modules: ['Numeric', '_curses', '_dummy_thread', '_ivp.BDF', '_ivp.DOP853', '_ivp.DenseOutput', '_ivp.LSODA', '_ivp.OdeSolution', '_ivp.OdeSolver', '_ivp.RK23', '_ivp.RK45', '_ivp.Radau', '_ivp.solve_ivp', '_levy_stable.levy_stable', '_posixshmem', '_posixsubprocess', '_scproxy', '_trlib.get_trlib_quadratic_subproblem', '_trustregion_constr._minimize_trustregion_constr', '_typeshed', '_uarray._Function', '_ufunc', 'cffi', 'com.sun', 'com.sun.jna', 'com.sun.jna.platform', 'core.abs', 'core.max', 'core.min', 'core.round', 'dummy.Process', 'extern.jaraco.functools', 'extern.jaraco.text', 'extern.more_itertools', 'fft.fft', 'fft.ifft', 'fft.irfft', 'fft.rfft', 'grp', 'importlib_metadata', 'linalg.norm', 'matplotlib', 'matplotlib.collections', 'matplotlib.pyplot', 'matplotlib.ticker', 'multiprocessing.AuthenticationError', 'multiprocessing.BufferTooShort', 'multiprocessing.TimeoutError', 'multiprocessing.get_context', 'multiprocessing.get_start_method', 'multiprocessing.set_start_method', 'nose', 'nose.plugins', 'nose.plugins.base', 'nose.plugins.builtin', 'nose.plugins.errorclass', 'nose.util', 'numarray', 'numpy_distutils.command.build_flib', 'numpy_distutils.command.cpuinfo', 'numpy_distutils.cpuinfo', 'numpy_distutils.fcompiler', 'org.python.modules.posix.PosixModule', 'packaging', 'pickle5', 'pkg_resources.extern.appdirs', 'pkg_resources.extern.jaraco.text', 'pkg_resources.extern.packaging', 'psutil', 'pytest', 'resource', 'scikits.umfpack', 'setuptools.extern.importlib_metadata', 'setuptools.extern.importlib_resources', 'setuptools.extern.jaraco.text', 'setuptools.extern.more_itertools', 'setuptools.extern.ordered_set', 'setuptools.extern.packaging', 'setuptools.extern.packaging.requirements', 'setuptools.extern.packaging.specifiers', 'setuptools.extern.packaging.tags', 'setuptools.extern.packaging.utils', 'setuptools.extern.packaging.version', 'setuptools.extern.pyparsing', 'setuptools.extern.tomli', 'sitecustomize', 'sksparse', 'sksparse.cholmod', 'sparse', 'special.loggamma', 'special.poch', 'special.rel_entr', 'sphinx.ext.autodoc', 'testing.Tester', 'trove_classifiers', 'typing_extensions', 'uarray', 'win32com.shell', 'win32con', 'win32pdh', 'yaml']
warning: build_apps: could not find dependency api-ms-win-core-path-l1-1-0.dll (referenced by python39.dll)

warning: build_apps: could not find dependency api-ms-win-crt-private-l1-1-0.dll (referenced by scipy.optimize.__nnls.pyd)

warning: build_apps: could not find dependency VCRUNTIME140_1.dll (referenced by geos-da1d0573fe2d0951fd7deec2c381e798.dll)

warning: build_apps: could not find dependency VCRUNTIME140_1.dll (referenced by geos_c-5bae93b523aae0b32120fb148e074738.dll)

warning: build_apps: _testcapi.pyd was not found in any downloaded wheel, is a dependency missing from requirements.txt?

warning: build_apps: _testinternalcapi.pyd was not found in any downloaded wheel, is a dependency missing from requirements.txt?

Copying game files for platform: win_amd64

Writing /c/Users/Josh/PycharmProjects/CTCAM/venv/Scripts/build/win_amd64/Setup/gridBack.egg.bam

Writing /c/Users/Josh/PycharmProjects/CTCAM/venv/Scripts/build/win_amd64/Setup/zup-axis.egg.bam

C:\Users\Josh\PycharmProjects\CTCAM\venv\Scripts>

Then running the executable generated, no window opens and the following is in the output log:

Traceback (most recent call last):
  File "__main__", line 21, in <module>
  File "importlib._bootstrap", line 1007, in _find_and_load
  File "importlib._bootstrap", line 972, in _find_and_load_unlocked
  File "importlib._bootstrap", line 228, in _call_with_frames_removed
  File "importlib._bootstrap", line 1007, in _find_and_load
  File "importlib._bootstrap", line 972, in _find_and_load_unlocked
  File "importlib._bootstrap", line 228, in _call_with_frames_removed
  File "importlib._bootstrap", line 1007, in _find_and_load
  File "importlib._bootstrap", line 986, in _find_and_load_unlocked
  File "importlib._bootstrap", line 680, in _load_unlocked
  File "importlib._bootstrap", line 838, in exec_module
  File "shapely", line 26, in <module>
  File "shapely", line 14, in _delvewheel_init_patch_1_2_0
  File "os", line 1111, in add_dll_directory
FileNotFoundError: [WinError 2] The system cannot find the file specified: 'C:\\Users\\Josh\\PycharmProjects\\CTCAM\\venv\\Scripts\\build\\shapely.libs'

Any help would be appreciated, Thanks.

First of all, greetings, and welcome to the forum! I hope that you find your time here to be both helpful and enjoyable! :slight_smile:

As to your question, I’m guessing somewhat, but perhaps it might help to instruct the build-system to incorporate those two libraries into the build via the “include_modules” option.

(Which allows one to explicitly specify modules to be incorporated that might otherwise be missed, and thus found to be missing at runtime.)

The syntax might look something like this, I think:

# (Within the "options" dictionary of your "setup.py" file, alongside
#  things like "include_patterns".)
    "include_modules" : {
        "*" : [
                "shapely",
                "meshcut",
              ]
              # Or however those modules are identified
    }

Thank you for the welcome and thanks for the reply. Unfortunately it did not resolve the issue. In fact, I didn’t notice any real change when adding this.

Is there more information I can provide so we can work together to resolve this?

May also be helpful to mention that when I rearrange the imports so that the meshcut import is first, the library that is missing is scipy. However, I tried declaring it in the same form and this also didn’t resolve the issue.

Do you have an example of using this function (build_apps) with a program that had dependency packages not directly included with python?

Please file an issue on our GitHub issue tracker, we probably need to add a special case to the build system for shapely.

As a workaround you could manually copy the shapely.libs directory from the shapely .whl (it’s a .zip file) to the built game directory.

1 Like

Thank you for your help that worked for my needs! I did file the issue on the Github for shapely / scipy and that was my first time doing that so, apologies if it is not exactly correct/complete.

For posterity, the issue is filed here, where further status on this will be reported: