1

I have a Python script which has been created to pull data out of a database and present it in an excel spreadsheet. Because multiple people need this script, I have placed the script on a network drive. To run the script, I have also created a virtual environment in a folder on my workstation, which I then copied to the network location. I have a batch file which runs the script using the virtual environment version of Python.

When I run the batch file on my workstation (from the network drive), everything works fine. When another user, who does not have Python installed on their workstation, runs the batch file, they receive the following error:

ModuleNotFoundError: No module named 'contextlib'

The traceback for the error comes from:

virtualenv\lib\site.py

virtualenv\lib\importlib\util.py

Is there something that I am missing when creating the virtual environment? To create it, I used the following commands (on Windows):

mkdir virtualenv
virtualenv virtualenv
\virtualenv\Scripts\activate
pip install [packages required for script]]
\virtualenv\Scripts\deactivate

Any help is very much appreciated.

kyle
  • 691
  • 1
  • 7
  • 17
Tristan
  • 153
  • 2
  • 11
  • Possible duplicate of [Python 3 virtualenv problems](https://stackoverflow.com/questions/28923926/python-3-virtualenv-problems) – gold_cy Feb 18 '19 at 23:21
  • Possible duplicate of [Relocating virtual environment project from local to server (flask project), have to install dependencies again?](https://stackoverflow.com/questions/25225853/relocating-virtual-environment-project-from-local-to-server-flask-project-hav) – phd Feb 18 '19 at 23:36
  • https://stackoverflow.com/search?q=%5Bvirtualenv%5D+network+drive – phd Feb 18 '19 at 23:36
  • https://stackoverflow.com/questions/52879962/how-to-run-a-python-script-locally-in-a-virtual-environment-on-someone-elses-win – phd Feb 18 '19 at 23:37

1 Answers1

0

Thanks for your help. It turns out that a virtualenv does not do what I thought it did. A virtialenv is not portable to other machines/evironments.

I ended up going with pyinstaller to package the script into an application. This was very easy and quick.

To install pyinstaller and create the app, I simply followed the instructions here:

https://www.pyinstaller.org/

Tristan
  • 153
  • 2
  • 11