1

I am having difficulty accessing my custom scripts from the command line (python3 unzipit.py "C:\Users\Me\downloads\zipfilehome"). I want to have my scripts act on any file, no matter where they are. I don't want to have the script file in the same directory in order for it to work. I followed this question's top answer to no avail. Note: I am using Windows 10 and all my python versions are in the path with no issues accessing them.

What I did (I always refresh my CLI with every change)

In the system environmental variables:

Path: (unchanged since installation) C:\Path2Python27;C:\Path2Python27\scripts;C:\Path2Python37;C:\Path2Python37\scripts;

PYTHONPATH: C:\Path2Python37;C:\Path2Python37\scripts;C:\Users\Me\myscripts\py

Things I also tried

  • system environmental variables

Path: C:\Path2Python27;C:\Path2Python27\scripts;C:\Path2Python37;C:\Path2Python37\scripts;C:\Users\Me\myscripts\py

  • moving the same stuff to user env's Path
  • moving the above-shown system PYTHONPATH to the user env

What else am I missing? I don't understand.


All in all, what I needed to get this working:

system environmental variables

Path: C:\Path2Python27;C:\Path2Python27\scripts;C:\Path2Python37;C:\Path2Python37\scripts;

PYTHONPATH: C:\Users\Me\myscripts\py

and

making sure to use Andriy's comment. It won't work using python3 unzipit.py "C:\link\to\folder".

user2986242
  • 477
  • 1
  • 5
  • 19

1 Answers1

1

In order to achieve what you want you have to specify -m flag and the module name, so python will retrieve module by looking up python module path. See more here in interface-options. The command shall be:

python3 -m unzipit "C:\Users\Me\downloads\zipfilehome"
Andriy Ivaneyko
  • 20,639
  • 6
  • 60
  • 82
  • I tried that and got `C:\Path2Python37\python3.exe: Error while finding module specification for 'unzipit.py' (ModuleNotFoundError: __path__ attribute not found on 'unzipit' while trying to find 'unzipit.py')`. – user2986242 Jul 08 '19 at 12:23
  • 1
    Oh, I was supposed to remove the `.py` extension. – user2986242 Jul 08 '19 at 12:36