What can I do to resolve the "ModuleError: No module named 'new'" problem?
What can I do to resolve the "ModuleError: No module named 'new'" problem?
我正在尝试 运行 一个程序,但我收到一条错误消息:
Traceback (most recent call last):
File "C:\Users\mmv456\AppData\Local\Programs\Python\Python36\lib\site.py", line 168, in addpackage
exec(line)
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'new'
我试图在那个目录中找到这个 site.py 文件,但它不在那里,所以我看不出 python 文件中的问题到底是什么。感谢您对此提供的任何帮助。
编辑:添加代码:
import collections
import itertools
import sys
if sys.platform == 'cli':
import System
CPU_COUNT = System.Environment.ProcessorCount
else:
#try:
# import multiprocessing
# CPU_COUNT = multiprocessing.cpu_count()
#except ImportError:
# CPU_COUNT = 1
# IronPython seems to be the only common Python implementation that doesn't
# have a GIL and therefore the only implementation that benefits from this.
# Therefore, don't bother making any threads on other implementations.
CPU_COUNT = 1
try:
import thread
import threading
except ImportError:
import dummy_threading as threading
import _dummy_thread as thread
CPU_COUNT = 1
ModuleNotFoundError: No module named 'new'
这一行表示您的导入有误。
当我 运行 您刚刚发布的代码时 运行 非常完美,但是如果我添加 import new 它会给出与您一样的确切错误:
import collections
import itertools
import sys
import new # I just added
if sys.platform == 'cli':
import System
CPU_COUNT = System.Environment.ProcessorCount
else:
#try:
# import multiprocessing
# CPU_COUNT = multiprocessing.cpu_count()
#except ImportError:
# CPU_COUNT = 1
# IronPython seems to be the only common Python implementation that doesn't
# have a GIL and therefore the only implementation that benefits from this.
# Therefore, don't bother making any threads on other implementations.
CPU_COUNT = 1
try:
import thread
import threading
except ImportError:
import dummy_threading as threading
import _dummy_thread as thread
CPU_COUNT = 1
错误:
(python37) C:\Users\Documents>py test.py
Traceback (most recent call last):
File "test.py", line 685, in <module>
import new
ModuleNotFoundError: No module named 'new'
但问题是我的错误在 test.py
中,但你指向的是 site.py
,它在 python 库中。这意味着您的 python 环境出了问题。甚至全世界都有类似的issues
Simple solution is uninstalling and reinstalling your python
environment.
我正在尝试 运行 一个程序,但我收到一条错误消息:
Traceback (most recent call last):
File "C:\Users\mmv456\AppData\Local\Programs\Python\Python36\lib\site.py", line 168, in addpackage
exec(line)
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'new'
我试图在那个目录中找到这个 site.py 文件,但它不在那里,所以我看不出 python 文件中的问题到底是什么。感谢您对此提供的任何帮助。
编辑:添加代码:
import collections
import itertools
import sys
if sys.platform == 'cli':
import System
CPU_COUNT = System.Environment.ProcessorCount
else:
#try:
# import multiprocessing
# CPU_COUNT = multiprocessing.cpu_count()
#except ImportError:
# CPU_COUNT = 1
# IronPython seems to be the only common Python implementation that doesn't
# have a GIL and therefore the only implementation that benefits from this.
# Therefore, don't bother making any threads on other implementations.
CPU_COUNT = 1
try:
import thread
import threading
except ImportError:
import dummy_threading as threading
import _dummy_thread as thread
CPU_COUNT = 1
ModuleNotFoundError: No module named 'new'
这一行表示您的导入有误。
当我 运行 您刚刚发布的代码时 运行 非常完美,但是如果我添加 import new 它会给出与您一样的确切错误:
import collections
import itertools
import sys
import new # I just added
if sys.platform == 'cli':
import System
CPU_COUNT = System.Environment.ProcessorCount
else:
#try:
# import multiprocessing
# CPU_COUNT = multiprocessing.cpu_count()
#except ImportError:
# CPU_COUNT = 1
# IronPython seems to be the only common Python implementation that doesn't
# have a GIL and therefore the only implementation that benefits from this.
# Therefore, don't bother making any threads on other implementations.
CPU_COUNT = 1
try:
import thread
import threading
except ImportError:
import dummy_threading as threading
import _dummy_thread as thread
CPU_COUNT = 1
错误:
(python37) C:\Users\Documents>py test.py
Traceback (most recent call last):
File "test.py", line 685, in <module>
import new
ModuleNotFoundError: No module named 'new'
但问题是我的错误在 test.py
中,但你指向的是 site.py
,它在 python 库中。这意味着您的 python 环境出了问题。甚至全世界都有类似的issues
Simple solution is uninstalling and reinstalling your python environment.