Seed
Seed

Reputation: 1

How to import module in pydroid

I'm having problems in importing my created module in pydroid 3. The process seems very simple in desktop version of python 3 but I tried doing it in Mobile in pydroid 3 application, but it does not work.

The output was "no module named ‘mymodule’ found".

This is my module saved as mymodule.py:

def sky(name):
  return ("Welcome, " + name) 

Error:

Python 3.8.3 (default, May 27 2020, 02:08:17)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import mymodule
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'mymodule'

Upvotes: -2

Views: 7659

Answers (6)

Eliot Branco
Eliot Branco

Reputation: 23

I was also having the same problem, but after searching on the terminal for some time, I got the directory of modules.

Here's the path: /data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.8

Move your file to this directory.

Upvotes: 0

Ibrahim Ayoola
Ibrahim Ayoola

Reputation: 1

I was having the same problem too, then I moved the module to ru.iiec.pydroid3. Try it and see if it works.

Upvotes: 0

Thesk970
Thesk970

Reputation: 1

I had this problem too. I solved it by opening the file (the main file) directly on Pydroid3. When you open the a file outside the application (i.e., by other external file manager) Pydroid opens the file on a different directory/link like content://localhost:....

But when you open directly in Pydroid the file will be charged at original path (e.g. /storage/0/emulated/.../file.py) and Pydroid could recognize the module because you are in the correct path/directory.

Upvotes: 0

Juwon Ajibola
Juwon Ajibola

Reputation: 1

Put your module in the same directory as your project.

Note: Not saving your script (still has the name new on it) will automatically make it in the external storage (storage/emulated/0).

Upvotes: 0

Jamaal
Jamaal

Reputation: 1

Just make sure your module is saved in the same folder first the just type From followed by the name of your module and import your function then you can just print or do what ever you want with the module.

Also you can just import the whole module by importing it.

Upvotes: 0

DINOTICK
DINOTICK

Reputation: 1

I don't know what's going wrong with your module, but try putting it on PyPI (Website) go to the terminal in the app, and type: pip install Mymodule.

Upvotes: -1

Related Questions