-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodules.py
More file actions
34 lines (28 loc) · 875 Bytes
/
modules.py
File metadata and controls
34 lines (28 loc) · 875 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/python
# This script is used to install python modules that are needed for a package.
import sys
import subprocess
import os
cwd = os.getcwd()
os.chdir(cwd)
# Define module list.
modules = ['pandas',
'xlsxwriter',
'oauth2client',
'gspread',
'numpy']
for item in modules:
# Implement pip as a subprocess:
subprocess.check_call([sys.executable, '-m', 'pip', 'install',
item])
# Process output with an API in the subprocess module:
reqs = subprocess.check_output([sys.executable, '-m', 'pip',
'freeze'])
installed_packages = [r.decode().split('==')[0] for r in reqs.split()]
packageString = ''
for item in installed_packages:
packageString += item + ',\n'
packageString = packageString[:-2]
outputFile = open("Installed_Packages.txt", "w")
# Write output to file.
outputFile.writelines(packageString)