RapydScript icon indicating copy to clipboard operation
RapydScript copied to clipboard

Cannot resolve python imports

Open markb-trustifi opened this issue 5 years ago • 8 comments

The compilation failed on importing local python module that exists in the same folder as the main file: import config

The shown error is:

[ImportError: Failed Import: 'config' module doesn't exist in any of the import directories: ./exampleservice-master, ./exampleservice-master/node_modules/rapydscript/src/lib] {
  message: "Failed Import: 'config' module doesn't exist in any of the import directories: ./exampleservice-master, ./exampleservice-master/node_modules/rapydscript/src/lib",
  filename: './exampleservice-master/statelesshosting.py',
  readfile_error: undefined
}

When I copied the config.py file into the src/lib folder it didn't find it too.

markb-trustifi avatar Jan 20 '20 17:01 markb-trustifi

Use .pyj, not .py

valq7711 avatar Jan 20 '20 17:01 valq7711

And how do I import standard python libraries that are installed by pip install -r requirements.txt?

markb-trustifi avatar Jan 20 '20 17:01 markb-trustifi

It is impossible, but you can try Transcrypt or Brython

valq7711 avatar Jan 20 '20 17:01 valq7711

Is there a way to make script don't fail on missing imports? You could create mock modules with mock classes.

markb-trustifi avatar Jan 20 '20 17:01 markb-trustifi

RS is mainly intended for writing Javascript using Python syntax, it is not compatible with Python, it just looks like Python, but it is javascript. So, explain in more detail what are you trying to do?

valq7711 avatar Jan 20 '20 18:01 valq7711

I would like to convert python project to JS

markb-trustifi avatar Jan 20 '20 19:01 markb-trustifi

What does your project look like? Should it be running in a browser or on Node.js? If it is large enough, then it is better to take a look at Transcrypt, because to convert it to RS you have to fix each file yourself. There are some fundamental differences, such as Truthiness/Falseness: [], {}- are considered as true in RS

valq7711 avatar Jan 20 '20 20:01 valq7711

It is a python backend server with bottle.py that should run like Node.js with express.js. I'm not looking for a complete solution. Just translating the syntax would be enough.

markb-trustifi avatar Jan 20 '20 22:01 markb-trustifi