0

I wrote a python script that acts as a Unix command line argument (if it's saved in the working directory).

If I downloaded external modules to use in this script, would someone on the same network (who doesn't have this module installed on their computer) still be able to run the script from their computer? If not, how can I get around this?

Thanks in advance... Please let me know if there's anything I can clarify about my question.

1 Answer 1

1

If you import third-party modules in your script, then whoever runs it needs to have those available.

The Python solution would be to make your script into a package that has a setup.py that specifies scripts and also requires your dependencies. When someone installs the package using python setup.py install or a package manager, it will put the script into a directory on the path, make it executable and adjust the shebang line for the local environment.

E.g.:

from setuptools import setup
setup(
    name='name',
    version='1.0.0',
    scripts=['myscript_filename'],
    install_requires=['other_module'],
)

Note that a different system, entry_points is now recommended over scripts but it requires a different format - see the docs.

Sign up to request clarification or add additional context in comments.

2 Comments

in 'other_module' do I just put the name of the external module used in the script?
So for example if it depends on the requests library you would use install_requires=['requests'] You can also specify required versions - see the docs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.