ModuleNotFoundError: No module named '' . in the same folder - python

I have two python files(qq.py and ww.py) are in the same folder.
code in qq.py is:
print('123x')
code in ww.py is:
import qq
when I execute ww.py in CMD, the error was appered:
Traceback (most recent call last):
File "ww.py", line 1, in <module>
import qq ModuleNotFoundError: No module named 'qq'
I don't know if there are some configuration errors.
It would be great If someone can help me work through this issue.
This is my python version.
Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
enter image description here

I have changed the code in ww.py
import os
import sys
sys.path.append(os.getcwd())
import qq
now, ww.py can run well

Related

unable to import from bitcoinrpc.authproxy import AuthServiceProxy

Am getting a module not found error - from bitcoinrpc.authproxy import AuthServiceProxy. the log below you can see that import bitcoinrpc is ok. am I missing something or did authproxy move or ?? thx
PS C:\python38> cd c:\python39
PS C:\python39> python
Python 3.9.5 (tags/v3.9.5:0a7dcbd, May 3 2021, 17:27:52) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', 'C:\\Python39\\python39.zip', 'C:\\Python39\\DLLs', 'C:\\Python39\\lib', 'C:\\Python39', 'C:\\Python39\\lib\\site-packages']
>>> from bitcoinrpc.authproxy import AuthServiceProxy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'bitcoinrpc.authproxy'
>>> import bitcoinrpc
>>>

Python import statement only recognizes packages from certain directories?

This is one of the weirder issues I've come across and I can't figure out what is causing it.
I have a from x import x statement and it only works in certain file directories.
for example, from my userroot directory
C:\Users\admin>where python
C:\scoop\shims\python.exe
C:\Users\admin>python
Python 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:25:58) [MSC v.1500 64 bit
(AM D64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from influxdb import InfluxDBClient
>>> ^Z
I can import the package just fine - however when I go to the desktop (which is still apart of my user directory)
C:\Users\admin>cd Desktop
C:\Users\admin\Desktop>where python
C:\scoop\shims\python.exe
C:\Users\admin\Desktop>python
Python 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:25:58) [MSC v.1500 64 bit (AM D64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from influxdb import InfluxDBClient
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\scoop\apps\python27\current\lib\site-packages\influxdb\__init__.py",
line 9, in <module>
from .client import InfluxDBClient
File "C:\scoop\apps\python27\current\lib\site-packages\influxdb\client.py", li
ne 14, in <module>
import requests
File "C:\scoop\apps\python27\current\lib\site-packages\requests\__init__.py",
line 43, in <module>
import urllib3
File "C:\scoop\apps\python27\current\lib\site-packages\urllib3\__init__.py", l
ine 8, in <module>
from .connectionpool import (
File "C:\scoop\apps\python27\current\lib\site-packages\urllib3\connectionpool.
py", line 3, in <module>
import logging
File "logging.py", line 4, in <module>
from influxdb import InfluxDBClient
ImportError: cannot import name InfluxDBClient
>>> ^Z
So going into my desktop directory, though still using the same python.exe, will not allow my to import the same package.
What makes this more bizarre, if I look at the sys.path
C:\Users\admin\Desktop>python
Python 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:25:58) [MSC v.1500 64 bit (AM
D64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', 'C:\\scoop\\apps\\python27\\current\\python27.zip', 'C:\\scoop\\apps\\pytho
n27\\current\\DLLs', 'C:\\scoop\\apps\\python27\\current\\lib', 'C:\\scoop\\apps
\\python27\\current\\lib\\plat-win', 'C:\\scoop\\apps\\python27\\current\\lib\\l
ib-tk', 'C:\\scoop\\apps\\python27\\current', 'C:\\scoop\\apps\\python27\\curren
t\\lib\\site-packages']
>>> ^Z
And for the root directory -
C:\Users\admin\Desktop>cd..
C:\Users\admin>python
Python 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:25:58) [MSC v.1500 64 bit (AM
D64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', 'C:\\scoop\\apps\\python27\\current\\python27.zip', 'C:\\scoop\\apps\\pytho
n27\\current\\DLLs', 'C:\\scoop\\apps\\python27\\current\\lib', 'C:\\scoop\\apps
\\python27\\current\\lib\\plat-win', 'C:\\scoop\\apps\\python27\\current\\lib\\l
ib-tk', 'C:\\scoop\\apps\\python27\\current', 'C:\\scoop\\apps\\python27\\curren
t\\lib\\site-packages']
>>> ^Z
You can see they are exactly the same. I figured it might be an Environmental variable issue, but why would it work in the userroot and not on the useroot/Desktop? And this doesnt seem to be just a influxdb error, BeautifulSoup does the same thing.
This is being ran from an elevated cmd prompt on an admin account. I've tried uninstalling and reinstalling python. I've tried both python2 and python3. I've tried setting PYTHONPATH.
Any thoughts?
I am late to reply, but I guess I should for others who face the same problem. I was also facing the same problem with
from influxdb import InfluxDBClient
Then I tried
pip install influxdb-client
And then
from influxdb_client import InfluxDBClient
It worked for me. Hope this helps.

no module named matplotlib on windows

Facing this issue right now, saw the question:
no module named pylab on windows
I have annaconda and python 2.7 installed. I tried in the python shell:
Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 2015, 20:32:19) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named matplotlib
and received the following result. I've checked my PATH variable, and I'm not sure how to resolve.
Thanks in advance.

ImportError: DLL load failed with downloaded PYQT4. 64bit python2.7

I am going to run a GUI program with main.py
After I run the main.py with using cmd, it shows the result.
Traceback (most recent call last):
File "Main.py", line 1, in <module>
from MainGlobalVar import *
File "C:\G02FYP\MainGlobalVar.py", line 4, in <module
from NetworkConsole import *
File "C:\G02FYP\NetworkConsole.py", line 1, in <modul
from PyQt4.QtGui import *
ImportError: DLL load failed: %1 is not a valid Win32 application.
I have double-checked that my version is 64 and I have re-installed the PYQT4
with using 64bits and python 2.7.9
Moreover,if I type python in cmd, it shows:
C:\>python
Python 2.7.9 (default, Dec 10 2014, 12:24:55) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>>
What should i do for this importerror.

“ImportError: No module named scipy” after installing the scipy package

I need help with the scipy Python module. I installed it, but when I try to import it, I get an error (no module named scipy). Why?
Here's the output from my Python interpreter:
Python 2.7.8 (default, Jun 30 2014, 16:08:48) [MSC v.1500 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import scipy
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import scipy
ImportError: No module named scipy

Categories