Bach Pham
Bach Pham

Reputation: 69

Importing custom modules (.py files) into virtual environment

I created different virtual environments due to different dependencies requirements, one of which is running Python 2.7. I have three .py modules included in a folder, that folder is in the same directory as all my scripts. However, when I try import those three .py modules I got an error "ImportError: DLL load failed: The specified module could not be found.". I suspect that it is due to the Python Interpreter in VSCode being pointed towards my Python 2.7 virtual environment in which these three .py modules do not exist. My questions are :

  1. How can I "install" these three modules into my virtual environment ?
  2. Is there a quick way to install these three modules into all virtual environments ?

Thank you for your help.

Upvotes: 0

Views: 1480

Answers (1)

Waket Zheng
Waket Zheng

Reputation: 6331

You can create a setup.py, then install this folder as a module by pip

pip install -e /path/to/folder

See more at https://packaging.python.org/tutorials/packaging-projects/

Upvotes: 1

Related Questions