python-shell icon indicating copy to clipboard operation
python-shell copied to clipboard

No such file or directory error

Open vishaln79 opened this issue 6 years ago • 3 comments

I am trying to run a python script within node:
var options = {

    scriptPath: '/var/upload/file-importer',
    args: ["-f '"+files+"'", "-d " + destination, "-p " + path, "-u " + username, "-c  /var/upload/file-importer/config.json", "-e " + environment]

}

PythonShell.run('file-importer-lite.py', options, function (err) {

I am getting a: { Error: IOError: [Errno 2] No such file or directory: ' /var/upload/file-importer/config.json' at PythonShell.parseError (/var/upload/bridges/nodejs/node_modules/python-shell/index.js:184:17) at terminateIfNeeded (/var/upload/bridges/nodejs/node_modules/python-shell/index.js:98:28) at ChildProcess. (/var/upload/bridges/nodejs/node_modules/python-shell/index.js:89:9) at ChildProcess.emit (events.js:182:13) at Process.ChildProcess._handle.onexit (internal/child_process.js:237:12)

----- Python Traceback -----
File "/var/upload/file-importer/file-importer-lite.py", line 269, in <module>
  main()
File "/var/upload/file-importer/file-importer-lite.py", line 251, in main
  with open(config_path) as conf_file:

traceback: 'Traceback (most recent call last):\n File "/var/upload/file-importer/file-importer-lite.py", line 269, in \n main()\n File "/var/upload/file-importer/file-importer-lite.py", line 251, in main\n with open(config_path) as conf_file:\nIOError: [Errno 2] No such file or directory: ' /var/upload/file-importer/config.json'\n', executable: 'python', options: null, script: '/var/upload/file-importer/file-importer-lite.py', args: [ '-f '/var/upload/xxx.zip'', '-d xxx', '-p /xxxx/xxx', '-u xxx', '-c /var/upload/file-importer/config.json', '-e dev' ], exitCode: 1 }

error even though the file exists. What am I doing wrong? I even tried giving a relative path to this file, but to no avail.

Any suggestions? Thanks, Vishal.

vishaln79 avatar Jul 26 '18 15:07 vishaln79

I have a similar problem and I believe what it may be doing is looking in this path due to the script path, but I'm unsure. /var/upload/file-importer/var/upload/file-importer/config.json

If you found a resolution do please share. Thanks

alienbuild avatar Mar 04 '19 06:03 alienbuild

Having same issue

McToluene avatar Mar 27 '19 14:03 McToluene

Im not a collaborator, but I think you paths are wrong as they are neither absolute nor relative. Absolute paths would be something like this: 'C:/user/username/.../folderx/filex.py' and relative Paths use this Notation: './folderx/filex.py' ./ = same Directory, ../ = one Directory up ../../ = 2 Directorys up. You also can use the npm module 'path' and use path.resolve('yourPath'); At the end the full absolute Path should be printed by python shell.

telion2 avatar Aug 06 '19 19:08 telion2