![]() |
Running this script on Windows? - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Running this script on Windows? (/thread-26806.html) |
Running this script on Windows? - Winfried - May-14-2020 Hello, I need to run a Python script that contains the following lines : #! /usr/bin/env nix-shell #! nix-shell -i python3 -p "python3.withPackages(ps: with ps; [pandas scipy requests (python3Packages.callPackage ./openrouteservice-py.nix {})])" import sys import os import pandas as pd import requests from time import sleep from scipy.spatial import Delaunay from threading import Lock import pickle from pathlib import Path import openrouteservice import jsonI have the following questions: 1. What do the first lines do? 2. Can I get rid of them to run the script on Windows? 3. How do I check which packages I need to run it? Trial and error until it runs? Thank you. RE: Running this script on Windows? - snippsat - May-14-2020 (May-14-2020, 11:45 AM)Winfried Wrote: 1. What do the first lines do?These lines is called shebang ,and used on Linux.You can delete them,i never use shebang on Linux either. (May-14-2020, 11:45 AM)Winfried Wrote: 3. How do I check which packages I need to run it? Trial and error until it runs?Usually there is a usage/install instruction bye the maker that use these libraries in there code. # 3-party libraries import pandas as pd import requests from scipy.spatial import Delaunay import openrouteservice # Standard library(comes with python) from pathlib import Path from time import sleep from threading import Lock import pickle import json import sys import osQuick demo of venv that now comes with Python. It's virtual environments so it's like new Python instantiation that's isolated stuff,if you don't know what it is. # Make E:\div_code λ python -m venv test_env # Cd in E:\div_code λ cd test_env\ # Activate E:\div_code\test_env λ E:\div_code\test_env\Scripts\activate # Install (test_env) E:\div_code\test_env λ pip install requests pandas scipy openrouteservice Collecting requests ..... Successfully installed certifi-2020.4.5.1 chardet-3.0.4 idna-2.9 numpy-1.18.4 openrouteservice-2.3.0 pandas-1.0.3 python-dateutil-2.8.1 pytz-2020.1 requests-2.23.0 scipy-1.4.1 six-1.14.0 urllib3-1.25.9 # Test that it work (test_env) E:\div_code\test_env λ python Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 21:26:53) [MSC v.1916 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import pandas as pd >>> >>> import requests >>> >>> from scipy.spatial import Delaunay >>> >>> import openrouteservice >>> >>> exit()As mention Standard library modules comes with Python and need no install. So now have all that's needed,only missing code ![]() RE: Running this script on Windows? - Winfried - May-15-2020 Thanks much! |