0

I would like to specify multiple modules to install by version number.

If this is my setup.py:

How can I adjust the contents of the mods list to specify the version number?

    from cx_Freeze import setup, Executable
    import sys

    base = None

    if sys.platform == 'win32':
        base = None


    executables = [Executable("main.py", base=base)]

    mods = ["cachetools==3.0.0",
    "pyexcel-xlsx==0.5.6",
    "idna"]

    packages = mods
    options = {
        'build_exe': {
            'packages':packages,
        },

    }

    setup(
        name = "file_rename",
        options = options,
        version = "1",
        description = 'renames pdf consent forms',
        executables = executables
    )

Edit: The utilities.py file begins:

import os
from os.path import dirname
import json
import io
from google.cloud import vision

The error I get after applying the advice from @jpeg, is as follows: error

My pip freeze is:

appdirs==1.4.3
beautifulsoup4==4.7.1
cachetools==3.0.0
certifi==2018.11.29
chardet==3.0.4
cx-Freeze==5.1.1
dialogflow==0.5.1
dj-database-url==0.5.0
Django==2.1.4
django-heroku==0.3.1
et-xmlfile==1.0.1
google==2.0.1
google-api-core==1.6.0
google-auth==1.6.1
google-cloud==0.34.0
google-cloud-core==0.28.1
google-cloud-storage==1.13.1
google-cloud-vision==0.35.1
google-resumable-media==0.3.1
googleapis-common-protos==1.5.5
grpcio==1.16.1
gunicorn==19.6.0
idna==2.7
image==1.5.27
jdcal==1.4
lml==0.0.7
numpy==1.15.4
openpyxl==2.5.12
packaging==19.0
pandas==0.23.4
pdf2image==1.1.0
Pillow==5.3.0
protobuf==3.6.1
psycopg2==2.7.6.1
pyasn1==0.4.4
pyasn1-modules==0.2.2
pyexcel==0.5.10
pyexcel-io==0.5.11
pyexcel-xlsx==0.5.6
pyparsing==2.3.1
pypng==0.0.19
python-dateutil==2.7.5
pytz==2018.7
requests==2.21.0
rsa==4.0
six==1.11.0
soupsieve==1.7.3
texttable==1.5.0
urllib3==1.24.1
whitenoise==3.3.1
wincertstore==0.2
XlsxWriter==1.1.2

The issue doesn't show itself when running the script normally, only after my exe is created and run, does an error appear.

alwayscurious
  • 1,155
  • 1
  • 8
  • 18

1 Answers1

1

This is not possible from within the setup script (as far as I know). cx_Freeze makes an executable including exactly the same python version and configuration it is invoked with, see the documentation.

So you need to make a new python installation where you install all modules to the wished configuration using for example

python -m pip install cachetools==3.0.0

and invoke the setup script using for example

python setup.py build

where python stands for the python executable of your new installation.

You can have multiple python installations on a computer, each in a different directory and with different versions of the modules installed.

You could also use for example virtualenv to manage separate package installations for different projects, but it seems that using cx_Freeze from within a virtualenv needs some additional tweaking to work properly.

EDIT:

Try to replace the packages list by

packages = ['google']

in your setup script. See ModuleNotFoundError: No module named 'google' on python 3.6.7

jpeg
  • 2,372
  • 4
  • 18
  • 31
  • Thanks for the response. I did this, but I get the modulenotfound error. This doesn't happen when I run the script in my virtualenv without cx_freeze. That leads me to believe that the wrong versions are being used. Anything else I can try? – alwayscurious Feb 05 '19 at 09:31
  • Please post the complete error message and which command you ran to get this error. See how to create a [mcve]. Otherwise there are few chances that anybody can understand what is exactly your problem and tries to help you. – jpeg Feb 05 '19 at 09:37
  • @alwayscurious Thank you for the additions. I've added a corresponding suggestion to my answer. It would also be better if you could post the error message as text instead of an image, see [Why not upload images of code on SO when asking a question?](https://meta.stackoverflow.com/q/285551/8516269) – jpeg Feb 05 '19 at 12:21