Repository: iterative/dvc

Issue:
Error: google-api-python-client DistributionNotFound when dvc is installed from the .exe file on Windows
## Bug Report

I am trying to use `dvc push` command to push my data to a gdrive folder, but getting the following error. Also, I have added logs at the end.

pkg_resources.DistributionNotFound: The 'google-api-python-client' distribution was not found and is required by the application
 
### Please provide information about your setup
I am on Windows 10, and installed DVC by running the downloaded executable file from dvc.org website.

**Output of `dvc version`: 0.94.0**

**Additional Information (if any):**

$ dvc push -v

<pre><code>
2020-05-29 13:23:11,992 DEBUG: Trying to spawn '['C:\\Program Files (x86)\\DVC (Data Version Control)\\dvc.exe', 'daemon', '-q', 'updater']'
2020-05-29 13:23:17,521 DEBUG: Spawned '['C:\\Program Files (x86)\\DVC (Data Version Control)\\dvc.exe', 'daemon', '-q', 'updater']'
2020-05-29 13:23:17,526 DEBUG: PRAGMA user_version;
2020-05-29 13:23:17,527 DEBUG: fetched: [(3,)]
2020-05-29 13:23:17,527 DEBUG: CREATE TABLE IF NOT EXISTS state (inode INTEGER PRIMARY KEY, mtime TEXT NOT NULL, size TEXT NOT NULL, md5 TEXT NOT NULL, timestamp TEXT NOT NULL)
2020-05-29 13:23:17,528 DEBUG: CREATE TABLE IF NOT EXISTS state_info (count INTEGER)
2020-05-29 13:23:17,529 DEBUG: CREATE TABLE IF NOT EXISTS link_state (path TEXT PRIMARY KEY, inode INTEGER NOT NULL, mtime TEXT NOT NULL)
2020-05-29 13:23:17,530 DEBUG: INSERT OR IGNORE INTO state_info (count) SELECT 0 WHERE NOT EXISTS (SELECT * FROM state_info)
2020-05-29 13:23:17,532 DEBUG: PRAGMA user_version = 3;
2020-05-29 13:23:23,230 DEBUG: Assuming 'C:\Users\siddhartha\Documents\workdir\part-effectivity\.dvc\cache\92\cc4168a1e2bb7630fe3f42180ae792.dir' is unchanged since it is read-only
2020-05-29 13:23:23,231 DEBUG: Assuming 'C:\Users\siddhartha\Documents\workdir\part-effectivity\.dvc\cache\92\cc4168a1e2bb7630fe3f42180ae792.dir' is unchanged since it is read-only
2020-05-29 13:23:23,233 DEBUG: Assuming 'C:\Users\siddhartha\Documents\workdir\part-effectivity\.dvc\cache\6b\39415383ba8bfc212f48d7bb0983f7.dir' is unchanged since it is read-only
2020-05-29 13:23:23,234 DEBUG: Assuming 'C:\Users\siddhartha\Documents\workdir\part-effectivity\.dvc\cache\6b\39415383ba8bfc212f48d7bb0983f7.dir' is unchanged since it is read-only
2020-05-29 13:23:23,245 DEBUG: Preparing to upload data to 'gdrive://******************'
2020-05-29 13:23:23,246 DEBUG: Preparing to collect status from gdrive://******************
2020-05-29 13:23:23,247 DEBUG: Collecting information from local cache...
2020-05-29 13:23:23,251 DEBUG: Assuming 'C:\Users\siddhartha\Documents\workdir\part-effectivity\.dvc\cache\3a\eae1dab81b9328111b3fb5e9c22c3e' is unchanged since it is read-only
2020-05-29 13:23:23,252 DEBUG: Assuming 'C:\Users\siddhartha\Documents\workdir\part-effectivity\.dvc\cache\ce\a32ec9f982ad8a0f315d1bdd3006be' is unchanged since it is read-only
2020-05-29 13:23:23,256 DEBUG: Assuming 'C:\Users\siddhartha\Documents\workdir\part-effectivity\.dvc\cache\3e\2d64cd42daa604a1f9c57c4b8f2bde' is unchanged since it is read-only
2020-05-29 13:23:23,258 DEBUG: Assuming 'C:\Users\siddhartha\Documents\workdir\part-effectivity\.dvc\cache\0d\899cf8e33b41b01432c25d8b1b3ee6' is unchanged since it is read-only
2020-05-29 13:23:23,260 DEBUG: Assuming 'C:\Users\siddhartha\Documents\workdir\part-effectivity\.dvc\cache\6b\39415383ba8bfc212f48d7bb0983f7.dir' is unchanged since it is read-only
2020-05-29 13:23:23,263 DEBUG: Assuming 'C:\Users\siddhartha\Documents\workdir\part-effectivity\.dvc\cache\66\17830adea23ca5499183274527f392' is unchanged since it is read-only
2020-05-29 13:23:23,266 DEBUG: Assuming 'C:\Users\siddhartha\Documents\workdir\part-effectivity\.dvc\cache\75\32fb2db0af59aba36f40bd8f529ab6' is unchanged since it is read-only
2020-05-29 13:23:23,268 DEBUG: Assuming 'C:\Users\siddhartha\Documents\workdir\part-effectivity\.dvc\cache\64\e330d2e56282eb6a3db7f0da84b065' is unchanged since it is read-only
2020-05-29 13:23:23,269 DEBUG: Assuming 'C:\Users\siddhartha\Documents\workdir\part-effectivity\.dvc\cache\2a\ae27a17d8cac387f14d4f613ae4f94' is unchanged since it is read-only
2020-05-29 13:23:23,272 DEBUG: Assuming 'C:\Users\siddhartha\Documents\workdir\part-effectivity\.dvc\cache\a2\6307d0e6037cd4d6776a9d6a23c018' is unchanged since it is read-only
2020-05-29 13:23:23,276 DEBUG: Assuming 'C:\Users\siddhartha\Documents\workdir\part-effectivity\.dvc\cache\9a\b5f9d43eb4fbf244c886db544f960e' is unchanged since it is read-only
2020-05-29 13:23:23,280 DEBUG: Assuming 'C:\Users\siddhartha\Documents\workdir\part-effectivity\.dvc\cache\ff\7867bf4290d81f3e1af4946311e61f' is unchanged since it is read-only
2020-05-29 13:23:23,285 DEBUG: Assuming 'C:\Users\siddhartha\Documents\workdir\part-effectivity\.dvc\cache\90\0d0cb1139c5ddd823153bcc25e9df4' is unchanged since it is read-only
2020-05-29 13:23:23,288 DEBUG: Assuming 'C:\Users\siddhartha\Documents\workdir\part-effectivity\.dvc\cache\47\1a95af84203a9f8985c35c6876378c' is unchanged since it is read-only
2020-05-29 13:23:23,291 DEBUG: Assuming 'C:\Users\siddhartha\Documents\workdir\part-effectivity\.dvc\cache\81\7ec1976ab4408d6ebaa41c5aea7ec5' is unchanged since it is read-only
2020-05-29 13:23:23,295 DEBUG: Assuming 'C:\Users\siddhartha\Documents\workdir\part-effectivity\.dvc\cache\6e\d0b84b2b299b137da0a52e296c4a04' is unchanged since it is read-only
2020-05-29 13:23:23,299 DEBUG: Assuming 'C:\Users\siddhartha\Documents\workdir\part-effectivity\.dvc\cache\27\b2391d6715e24eaf4ced71974e118d' is unchanged since it is read-only
2020-05-29 13:23:23,301 DEBUG: Assuming 'C:\Users\siddhartha\Documents\workdir\part-effectivity\.dvc\cache\0b\613bd5bd27a1b60c19704933de64b0' is unchanged since it is read-only
2020-05-29 13:23:23,303 DEBUG: Assuming 'C:\Users\siddhartha\Documents\workdir\part-effectivity\.dvc\cache\53\478feb3572cace4a251c98a81d7336' is unchanged since it is read-only
2020-05-29 13:23:23,304 DEBUG: Assuming 'C:\Users\siddhartha\Documents\workdir\part-effectivity\.dvc\cache\00\42a1aa7bc91f4222e9ad013c35e77e' is unchanged since it is read-only
2020-05-29 13:23:23,309 DEBUG: Assuming 'C:\Users\siddhartha\Documents\workdir\part-effectivity\.dvc\cache\92\cc4168a1e2bb7630fe3f42180ae792.dir' is unchanged since it is read-only
2020-05-29 13:23:23,311 DEBUG: Assuming 'C:\Users\siddhartha\Documents\workdir\part-effectivity\.dvc\cache\ac\ce28152d2df01fb053772847dd5732' is unchanged since it is read-only
2020-05-29 13:23:23,315 DEBUG: Collecting information from remote cache...
2020-05-29 13:23:23,316 DEBUG: Querying 1 checksums via object_exists
2020-05-29 13:23:23,436 DEBUG: SELECT count from state_info WHERE rowid=?
2020-05-29 13:23:23,437 DEBUG: fetched: [(59,)]
2020-05-29 13:23:23,438 DEBUG: UPDATE state_info SET count = ? WHERE rowid = ?
2020-05-29 13:23:23,443 ERROR: unexpected error - The 'google-api-python-client' distribution was not found and is required by the application
------------------------------------------------------------
Traceback (most recent call last):
  File "site-packages\funcy\flow.py", line 122, in retry
  File "site-packages\funcy\decorators.py", line 60, in __call__
  File "dvc\remote\gdrive.py", line 336, in _gdrive_shared_drive_id
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "c:\python37\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
  File "site-packages\pydrive2\files.py", line 6, in <module>
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "c:\python37\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
  File "site-packages\googleapiclient\http.py", line 67, in <module>
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "c:\python37\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
  File "site-packages\googleapiclient\model.py", line 36, in <module>
  File "site-packages\pkg_resources\__init__.py", line 481, in get_distribution
  File "site-packages\pkg_resources\__init__.py", line 357, in get_provider
  File "site-packages\pkg_resources\__init__.py", line 900, in require
  File "site-packages\pkg_resources\__init__.py", line 786, in resolve
pkg_resources.DistributionNotFound: The 'google-api-python-client' distribution was not found and is required by the application

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "dvc\main.py", line 49, in main
  File "dvc\command\data_sync.py", line 55, in run
  File "dvc\repo\__init__.py", line 30, in wrapper
  File "dvc\repo\push.py", line 27, in push
  File "dvc\data_cloud.py", line 66, in push
  File "dvc\remote\base.py", line 80, in wrapper
  File "dvc\remote\local.py", line 567, in push
  File "dvc\remote\local.py", line 475, in _process
  File "dvc\remote\local.py", line 328, in _status
  File "dvc\remote\local.py", line 376, in _indexed_dir_checksums
  File "dvc\remote\base.py", line 1090, in _cache_object_exists
  File "concurrent\futures\_base.py", line 598, in result_iterator
  File "concurrent\futures\_base.py", line 435, in result
  File "concurrent\futures\_base.py", line 384, in __get_result
  File "concurrent\futures\thread.py", line 57, in run
  File "dvc\remote\base.py", line 1083, in exists_with_progress
  File "dvc\remote\gdrive.py", line 525, in exists
  File "dvc\remote\gdrive.py", line 516, in _get_item_id
  File "dvc\remote\gdrive.py", line 499, in _path_to_item_ids
  File "dvc\remote\gdrive.py", line 495, in _get_cached_item_ids
  File "site-packages\funcy\objects.py", line 50, in __get__
  File "site-packages\funcy\objects.py", line 28, in __get__
  File "dvc\remote\gdrive.py", line 307, in _ids_cache
  File "dvc\remote\gdrive.py", line 442, in _gdrive_list
  File "site-packages\funcy\objects.py", line 28, in __get__
  File "dvc\remote\gdrive.py", line 323, in _list_params
  File "site-packages\funcy\decorators.py", line 39, in wrapper
  File "site-packages\funcy\flow.py", line 124, in retry
  File "dvc\remote\gdrive.py", line 60, in should_retry
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "c:\python37\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
  File "site-packages\pydrive2\files.py", line 6, in <module>
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "c:\python37\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
  File "site-packages\googleapiclient\http.py", line 67, in <module>
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "c:\python37\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
  File "site-packages\googleapiclient\model.py", line 36, in <module>
  File "site-packages\pkg_resources\__init__.py", line 481, in get_distribution
  File "site-packages\pkg_resources\__init__.py", line 357, in get_provider
  File "site-packages\pkg_resources\__init__.py", line 900, in require
  File "site-packages\pkg_resources\__init__.py", line 786, in resolve
pkg_resources.DistributionNotFound: The 'google-api-python-client' distribution was not found and is required by the application
------------------------------------------------------------
</pre></code>



Discussion:
Discord context: https://discordapp.com/channels/485586884165107732/485596304961962003/715722364398075904
Most likely pyinstaller didn't include that particular lib, so we will probably need to add a hook for it.

Resolving patch:
diff --git a/scripts/hooks/hook-pydrive2.py b/scripts/hooks/hook-pydrive2.py
new file mode 100644
--- /dev/null
+++ b/scripts/hooks/hook-pydrive2.py
@@ -0,0 +1,4 @@
+from PyInstaller.utils.hooks import copy_metadata
+
+datas = copy_metadata("pydrive2")
+datas += copy_metadata("google-api-python-client")


Test patch: