{"cells":[{"metadata":{},"cell_type":"markdown","source":"This is an easy way to get your requirements.txt into a dataset so your other notebooks can install all the packages without internet. This notebook needs internet to download the packages and zip them. "},{"metadata":{},"cell_type":"markdown","source":"Instructions: \n\n1. Clone this notebook and enable internet\n2. Find the requirements section and paste your requirements.txt (pip freeze > requirements.txt) \n3. Commit the cloned notebook \n4. At the very bottom after the commit finished running, click new dataset, which will create a new dataset from the output\n5. Add the dataset to your other notebook \n6. replace datasetname with your dataset's name and run !pip install  -r /kaggle/input/datasetname/packages/requirements.txt --no-index --find-links file:///kaggle/input/datasetname/packages\n7. If you are having issues, run the walk command and it will print the paths (be careful not to print the paths to the training/test data). \n"},{"metadata":{"_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","trusted":true},"cell_type":"code","source":"import sys \nimport platform\nimport os \nimport zipfile \n\ndef get_env_info(): \n    \n    print(sys.platform)\n    print(platform.python_implementation())\n    print(sys.version)\n    \nget_env_info()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"os.mkdir('packages')","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"This is the requirements section. "},{"metadata":{"trusted":true},"cell_type":"code","source":"#copy paste your requirements file contents to here \n\nopen('packages/requirements.txt', 'w').write('''\nnumba\n''')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# download packages to directory \n!pip download -d packages -r packages/requirements.txt","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# #zip packages so you can create a dataset from them easily\n# #actually don't this is dumb. just create a new dataset from the output files\n# import shutil\n# shutil.make_archive('packages.zip', 'zip', 'packages')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# shutil.rmtree('packages')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"#extract again using below \n# shutil.unpack_archive('packages.zip.zip', 'packages')","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat":4,"nbformat_minor":4}