Home > Software design >  How to pass script path to Python 3.9 on Windows 10?
How to pass script path to Python 3.9 on Windows 10?

Time:11-20

From Windows 10 command line , Python 3.9.13, in directory:

C:\Users\foo.bar\wks\df\data

when trying to run :

python unilm\\layoutlm\\examples\\seq_labeling\\preprocess.py --data_dir FUNSD\\training_data\\annotations --data_split train --output_dir data --model_name_or_path microsoft/layoutlm-base-uncased --max_len 510

I get this error:

python: can't open file 'C:\Users\foo.bar\wks\df\data\unilm\layoutlm\examples\seq_labeling\preprocess.py': [Errno 2] No such file or directory

Notwithstanding the path C:\Users\foo.bar\wks\df\data\unilm\layoutlm\examples\seq_labeling\preprocess.py' is correct, really exists.

What's wrong?

CodePudding user response:

There are a few ways to do this:

  1. Use the -m flag:

python -m my_script.py

  1. Use the sys.argv list:

import sys sys.argv.append('my_script.py')

  1. Use the os.environ dictionary:

import os os.environ['PYTHONPATH'] = 'my_script.py'

  1. Use the site module:

import site site.addsitedir('my_script.py')

CodePudding user response:

The problem was in a typo in one of the words of the long path to a script. Thanks for trying to help and sorry for confusion!

  • Related