FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\Username\\sketchbook-pyp5js\\test\\__target__'
GokulNC opened this issue · 4 comments
After I pip install pyp5js
and pyp5js serve
and create a new sketch and go to that page, it shows me an Internal Server Error
.
I'm on Windows. It seems like there's some issue with the way you're passing arguments to transcrypt
to transpile target_sketch.py
.
Error logs
127.0.0.1 - - [15/Aug/2020 21:24:29] "GET /sketch/test HTTP/1.1" 308 -
Converting Python to P5.js...
Running command:
transcrypt -xp c:\program files\python38\lib\site-packages\pyp5js -k -ks -b -m -n C:\Users\Gokul\sketchbook-pyp5js\test\target_sketch.py
Transcrypt (TM) Python to JavaScript Small Sane Subset Transpiler Version 3.7.16
Copyright (C) Geatec Engineering. License: Apache 2.0
usage: transcrypt [-h] [-a] [-am] [-b] [-c] [-d] [-da] [-dc] [-de] [-dl] [-dm] [-dn] [-ds] [-dt] [-e [ESV]] [-ec] [-f]
[-g] [-i] [-jc] [-jk] [-jm] [-k] [-kc] [-l] [-m] [-n] [-o] [-p [PARENT]] [-r] [-s [SYMBOLS]] [-sf]
[-t] [-u [UNIT]] [-v] [-x X] [-xr] [-xg] [-xp [XPATH]] [-xt] [-*]
[source]
positional arguments:
source .py file containing source code of main module
optional arguments:
-h, --help show this help message and exit
-a, --anno annotate target files that were compiled from Python with source file names and source line
numbers
-am, --alimod use aliasing for module paths
-b, --build rebuild all target files from scratch
-c, --complex enable complex number support, locally requires operator overloading
-d, --docat enable __doc__ attributes. Apply sparsely, since it will make docstrings part of the generated
code
-da, --dassert debug: activate assertions
-dc, --dcheck debug: perform lightweight consistency check
-de, --dextex debug: show extended exception reports
-dl, --dlog debug: log compiler messages to disk
-dm, --dmap debug: dump human readable source map
-dn, --dnostrip debug: no comment stripping of __core__ and __builtin__ in-line modules
-ds, --dstat debug: validate static typing using annotations
-dt, --dtree debug: dump syntax tree
-e [ESV], --esv [ESV]
ecma script version of generated code, default = 6. The symbol __esv<versionnr>__ is added to
the global symbol list, e.g. __esv7__.
-ec, --ecom enable executable comments, seen as comments by CPython but as executable statements by
Transcrypt
-f, --fcall enable fastcall mechanism by default. You can also use __pragma__ ('fcal') and __pragma__
('nofcall')
-g, --gen enable generators and iterators. Disadvised, since it will result in a function call for each
loop iteration. Preferably use __pragma__ ('gen') and __pragma__ ('nogen')
-i, --iconv enable automatic conversion to iterable by default. Disadvised, since it will result in a type
check for each for-loop. Preferably use __pragma__ ('iconv') and __pragma__ ('noiconv') to
enable automatic conversion locally
-jc, --jscall enable native JavaScript calls for Python methods. This is fast, but doesn't support bound
method assignment, decorators and non-instance methods. Preferably use __pragma__ ('jscall')
and __pragma__ ('nojscall') to enable native JavaScript calls locally
-jk, --jskeys interpret {key: 'value'} as {'key': 'value'} and forbid {key (): 'value'}, as JavaScript does.
Disadvised, since it's less flexible than the Python interpretation. Either follow Python
semantics by using {'key': 'value'} explicitly if you want literal keys or use __pragma__
('jskeys') and __pragma__ ('nojskeys') locally instead to make clear local deviation from
Python semantics
-jm, --jsmod give % and %= JavaScript rather than Python behaviour. Disadvised, since it deviates from the
mathematical 'modulo' operator. Either follow Python semantics or use __pragma__ ('jsmod') and
__pragma__ ('nojsmod') locally instead to make clear local deviation.
-k, --kwargs enable keyword arguments by default. In general this is disadvised, use __pragma__ ('kwargs')
and __pragma__('nokwargs') locally instead to prevent bloated code
-kc, --keycheck enable checking for existence of dictionary keys. In general this is disadvised, use
__pragma__ ('keycheck') and __pragma__('nokeycheck') locally instead to prevent bloated code
-l, --license show license
-m, --map generate source map
-n, --nomin no minification
-o, --opov enable operator overloading by default. In general this is disadvised, use __pragma__ ('opov')
and __pragma__('noopov') locally instead to prevent slow code
-p [PARENT], --parent [PARENT]
object that will hold application, default is window. Use -p .none to generate orphan
application, e.g. for use in node.js
-r, --run run source file rather than compiling it
-s [SYMBOLS], --symbols [SYMBOLS]
names, joined by $, separately passed to main module in __symbols__ variable
-sf, --sform enable support for string formatting mini language
-t, --tconv enable automatic conversion to truth value by default. Disadvised, since it will result in a
conversion for each boolean. Preferably use __pragma__ ('tconv') and __pragma__ ('notconv') to
enable automatic conversion locally
-u [UNIT], --unit [UNIT]
compile to units rather than to monolithic application. Use -u .auto to autogenerate
dynamically loadable native JavaScript modules, one per Python module. Use -u .run to generate
the loader and the staticcally loadable runtime unit. Use -u .com to generate a statically
loadable component unit.
-v, --verbose show all messages
-x X, --x X reserved for extended options
-xr, --xreex re-export all imported names
-xg, --xglobs allow use of the 'globals' function
-xp [XPATH], --xpath [XPATH]
additional module search paths, joined by $, #'s will be replaced by spaces
-xt, --xtiny generate tiny version of runtime, a.o. lacking support for implicit and explicit operator
overloading. Use only if generated code can be validated, since it will introduce semantic
alterations in edge cases
-*, --star Like it? Grow it! Go to GitHub and then click [* Star]
Error: unrecognized arguments: C:\Users\Gokul\sketchbook-pyp5js\test\target_sketch.py
Aborted
[2020-08-15 21:24:30,279] ERROR in app: Exception on /sketch/test/ [GET]
Traceback (most recent call last):
File "c:\program files\python38\lib\shutil.py", line 788, in move
os.rename(src, real_dst)
FileNotFoundError: [WinError 2] The system cannot find the file specified: 'C:\\Users\\Gokul\\sketchbook-pyp5js\\test\\__target__' -> 'C:\\Users\\Gokul\\sketchbook-pyp5js\\test\\target'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\program files\python38\lib\site-packages\flask\app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "c:\program files\python38\lib\site-packages\flask\app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "c:\program files\python38\lib\site-packages\flask\app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "c:\program files\python38\lib\site-packages\flask\_compat.py", line 39, in reraise
raise value
File "c:\program files\python38\lib\site-packages\flask\app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "c:\program files\python38\lib\site-packages\flask\app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "c:\program files\python38\lib\site-packages\pyp5js\http\web_app.py", line 83, in render_sketch_view
commands.transcrypt_sketch(sketch_name)
File "c:\program files\python38\lib\site-packages\pyp5js\commands.py", line 57, in transcrypt_sketch
compile_sketch_js(sketch_files)
File "c:\program files\python38\lib\site-packages\pyp5js\compiler.py", line 70, in compile_sketch_js
compiler.compile_sketch_js()
File "c:\program files\python38\lib\site-packages\pyp5js\compiler.py", line 17, in compile_sketch_js
self.clean_up()
File "c:\program files\python38\lib\site-packages\pyp5js\compiler.py", line 54, in clean_up
shutil.move(self.target_dir, self.sketch_files.target_dir)
File "c:\program files\python38\lib\shutil.py", line 802, in move
copy_function(src, real_dst)
File "c:\program files\python38\lib\shutil.py", line 432, in copy2
copyfile(src, dst, follow_symlinks=follow_symlinks)
File "c:\program files\python38\lib\shutil.py", line 261, in copyfile
with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\Gokul\\sketchbook-pyp5js\\test\\__target__'
I also tried manually heading to that directory and running: pyp5js transcrypt test
, but I get the same error.
(test
is my sketch name with script test.py
)
Please check.
Ok. Turns out it's because of the space in the pathname. Transpiling manually with single quotes did it:
transcrypt -xp 'c:\program files\python38\lib\site-packages\pyp5js' -k -ks -b -m -n C:\Users\Gokul\sketchbook-pyp5js\test\target_sketch.py
So please do quote all the paths before passing it to the transcrypt
binary.
Thanks for the issue and the investigation about what was causing it @GokulNC =) I'll try to fix this as soon as possible
Hi @GokulNC! I fixed this issue and release the new 0.4.4 version with it. Now you should be able to use pyp5js again =)
Thanks a lot! 👍
Have a good day brother.