How to import module in pydroid - python

I'm having problem 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
When I created my module using Def and saved with 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 "", line 1, in
ModuleNotFoundError: No module named 'mymodule'

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

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. I hope it will help you.

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.

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.

Related

ImportError: dynamic module does not define module export function (PyInit_cx_Oracle)

I compiled python3.8 on a half dozen servers (SUSE Linux) and it is working fine on most of them.
But on one, it throws this weird error when I try to install and use the cx_Oracle library.
I set up a virtual environment, and pip install cx_Oracle (version 8.0.0). The installation works fine, but then when I try to import cx_Oracle, it throws an error:
[GCC 4.8.5] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cx_Oracle
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dynamic module does not define module export function (PyInit_cx_Oracle)
>>>
Not sure what to look for here. Any thoughts on what the problem might be, or how to trace this out?
Fixed! It turned out there was a PYTHONPATH environment variable active that was pointing to the old Python 2.7 folders, even though I was in a Python 3.8 virtual environment. After deleting that environment variable, it started working.
More info with how we diagnosed it here:
https://github.com/oracle/python-cx_Oracle/issues/464

How do I diagnose ImportError: DLL load failed when loading native Windows python modules in a virtualenv?

I am using Python 3.x and a virtualenv -- not conda, just a plain virtualenv.
I activate the venv and run pip install opencv-python. However,
import cv2 gives me a DLL not found error:
(tf) C:\>python
Python 3.6.2 (v3.6.2:5fd33b5, Jul 8 2017, 04:57:36) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\src\venv\tf\lib\site-packages\cv2\__init__.py", line 4, in <module>
from .cv2 import *
ImportError: DLL load failed: The specified module could not be found.
>>>
Is this a virtualenv bug? How do I figure out which module/dll is missing?
On resolving "module could not be found" errors in general
Try using either Microsoft's Dependency Walker or lucasg's Dependencies on the module being loaded. Be sure to run Dependencies.exe from your virtualenv's command prompt, so it picks up your modified PATH.
The import line is from .cv2 import *, so the module being loaded is in the same directory as __init__.py (this is the leading .) and named cv2-SOMETHING.pyd (this is what native Python modules look like). Load that file into Dependencies.exe and it will show you the DLL that Windows wants but can't find.
In this case, the DLL is Python3.dll. Why is it missing? Because of a virtualenv bug that is fixed, but hasn't made its way into a release -- there hasn't been a release in more than a year.
On resolving this issue in particular
The github issue suggests a fix: use venv.
Alternatively you can copy the missing python3.dll into your virtualenv by hand. You'll have to do this for every virtualenv you create.
copy "c:\Program Files\Python36\python3.dll" "c:\src\venv\tf\Scripts\"

No module names django.core, but I can import django from the shell

When I run django in a virtual environment, I get No module named 'django.core':
(proj)[jenia#li app]$ python manage.py runserver
Traceback (most recent call last):
File "manage.py", line 8, in <module>
from django.core.management import execute_from_command_line
ImportError: No module named 'django.core'
However, when I run the Python interpreter, and import django, there's no error message:
(proj)[jenia#li app]$ python
Python 3.4.1 (default, May 19 2014, 17:23:49)
[GCC 4.9.0 20140507 (prerelease)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>>
>>> import django
>>>
When I import django.core it fails of course.
What am I doing wrong? What could this be related to?
Thanks in advance?
I think you have no django installed at all or you have similar called folder or py-file in current directory.
You can print django.__path__ and I bet it will point to some script, called django.py or package folder django, which is not a django.
You should rename it, so import will look deeper, to python-packages, where real django is located.

Why is this module not being found when I run the script but is in the interpreter?

I'm trying to import the tkinter module into my script. I have it installed since the interpreter is able to import it with no problems:
C:\Users\Nacht\Dropbox\Scripts>python
Python 3.2.2 (default, Sep 4 2011, 09:51:08) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter
>>>
Imports fine, no problem. But now when I try to run a script that has the line import tkinter....
C:\Users\Nacht\Dropbox\Scripts>t ls
Traceback (most recent call last):
File "C:\Users\Nacht\Dropbox\Scripts\t.py", line 5, in <module>
import tkinter
ImportError: No module named tkinter
where t is the name of the script and ls a command (it is a command-line interface).
How can the interpreter see it but not the script? Thanks.
EDIT:
The sys.path says, for the interpreter:
C:\Python32\lib\site-packages\distribute-0.6.24-py3.2.egg
C:\Python32\lib\site-packages\selenium-2.15.0-py3.2.egg
C:\Windows\system32\python32.zip
C:\Python32\DLLs
C:\Python32\lib
C:\Python32
C:\Python32\lib\site-packages
C:\Python32\lib\site-packages\win32
C:\Python32\lib\site-packages\win32\lib
C:\Python32\lib\site-packages\Pythonwin
and for the script:
C:\Users\Nacht\Dropbox\Scripts
C:\Python27\lib\site-packages\distribute-0.6.24-py2.7.egg
C:\Windows\system32\python27.zip
C:\Python27\DLLs
C:\Python27\lib
C:\Python27\lib\plat-win
C:\Python27\lib\lib-tk
C:\Python27
C:\Python27\lib\site-packages
C:\Python27\lib\site-packages\setuptools-0.6c11-py2.7.egg-info
The script appears to be running with Python 2.7 but when you run the interpreter directly, it is using Python 3.2. As mentioned by #DSM, the name of Tkinter was different (perhaps there are other differences?).
May be there is a problem with path. It can't find the tkinter module. Setting up correct path try to import again.

Unable to import Python's email module at all

I can't seem to import the email module at all. Every time I do it I get an error. I've tried uninstalling Python and reinstalling, but the email module just refuses to work. I've even done "pip install email" and it's still broken. I'm on Windows 7 Home Premium x64, running an x86 version of Python.
Here's what happens:
c:\Users\Nicholas\Desktop>python
ActivePython 2.7.2.5 (ActiveState Software Inc.) based on
Python 2.7.2 (default, Jun 24 2011, 12:21:10) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> import email
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "email.py", line 1, in <module>
import smtplib
File "C:\Python27\lib\smtplib.py", line 46, in <module>
import email.utils
ImportError: No module named utils
>>>
EDIT: I've tried both Python from python.org and ActivePython, thinking ActivePython might work. Is there anyway to completely remove python and all its data and start 100% fresh maybe?
It looks like you have a file named email.py. Don't use file names that have the same name as Python standard library modules. Generally, your working directory comes earlier on the Python search path for importing modules so files in your working directory will override modules with the same name in the standard library.
The clue: note the path names in the traceback
File "email.py", line 1, in <module>
import smtplib
File "C:\Python27\lib\smtplib.py", line 46, in <module>
import email.utils
By the way, this is a very common error. The excellent tutorial in the Python standard documentation set talks about it here.
I just came across this error and wanted to share my solution. In my case, I had a file named email.py in directory. This created a name conflict between Python's email.py and my file. When smtplib tried to import email.utils it looked and my file and didn't find anything. After I renamed my copy of email.py into myemail.py everything worked like a charm.
I also came across this error. In addition to renaming the email.py to something else, you must also remove the email.pyc (notice the C) file. After that, all is well. Thanks all!
I also fetched this problem because i had a file named email.py in my project directory. I wasn't able to import urllib.request . When i changed the file name email.py to emailtest.py then the error gone away.
In every time we should not use the name what is same as python core file name.
If none of the posted solution works, try the following:
(Use the combo python3 / pip3 OR python / pip and try not to mix those)
Delete your current virtual environment directory.
Create new virtual environment and activate it with 'source'.
If exist, run the <pip install -r requirements.txt>.
Install any missing packages with pip or pip3.
Run the application to see if that solved the problem.
npm install email
has fix my problem, try it.

Categories

Resources