Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot resolve python imports #218

Open
markb-trustifi opened this issue Jan 20, 2020 · 8 comments
Open

Cannot resolve python imports #218

markb-trustifi opened this issue Jan 20, 2020 · 8 comments

Comments

@markb-trustifi
Copy link

markb-trustifi commented Jan 20, 2020

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.

@valq7711
Copy link
Collaborator

Use .pyj, not .py

@markb-trustifi
Copy link
Author

markb-trustifi commented Jan 20, 2020

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

@valq7711
Copy link
Collaborator

It is impossible, but you can try Transcrypt or Brython

@markb-trustifi
Copy link
Author

markb-trustifi commented Jan 20, 2020

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

@valq7711
Copy link
Collaborator

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?

@markb-trustifi
Copy link
Author

I would like to convert python project to JS

@valq7711
Copy link
Collaborator

valq7711 commented Jan 20, 2020

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

@markb-trustifi
Copy link
Author

markb-trustifi commented Jan 20, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants