python import module troubleshooting

博客讲述了在Python中导入munkres库时遇到问题,原因是自定义的Python文件命名为munkres.py,导致导入时出错。此外,还验证了很多库在Python2和Python3环境下无冲突,给出了导入错误的具体信息。

用到了一个叫做munkres的库

但每次import的时候都出现了问题

后来找到问题是我自己的python file 命名为munkres.py 

所以每次它import 的时候都是import 我自己的python file 

python 这一点也挺不好的,感觉就是很随意的,interpreter一脸懵逼?

还有问题是不是很多库都是python2 和python3 共同使用的,就是没有冲突,为了验证这一点我还特意搞了python2的环境,结果是没有冲突。

Traceback (most recent call last):
  File "f:/PythonDev/benchmarks/scripts/import_munres.py", line 5, in <module>

ImportError: cannot import name 'Munkres' from 'munkres' (f:\PythonDev\benchmarks\scripts\munkres.py)

Traceback (most recent call last): File "C:\Users\21904\PycharmProjects\PythonProject\.venv\lib\site-packages\numpy\_core\__init__.py", line 23, in <module> from . import multiarray File "C:\Users\21904\PycharmProjects\PythonProject\.venv\lib\site-packages\numpy\_core\multiarray.py", line 10, in <module> from . import overrides File "C:\Users\21904\PycharmProjects\PythonProject\.venv\lib\site-packages\numpy\_core\overrides.py", line 7, in <module> from numpy._core._multiarray_umath import ( ImportError: PyCapsule_Import could not import module "datetime" During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users\21904\PycharmProjects\PythonProject\.venv\lib\site-packages\numpy\__init__.py", line 114, in <module> from numpy.__config__ import show_config File "C:\Users\21904\PycharmProjects\PythonProject\.venv\lib\site-packages\numpy\__config__.py", line 4, in <module> from numpy._core._multiarray_umath import ( File "C:\Users\21904\PycharmProjects\PythonProject\.venv\lib\site-packages\numpy\_core\__init__.py", line 49, in <module> raise ImportError(msg) ImportError: IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE! Importing the numpy C-extensions failed. This error can happen for many reasons, often due to issues with your setup or how NumPy was installed. We have compiled some common reasons and troubleshooting tips at: https://numpy.org/devdocs/user/troubleshooting-importerror.html Please note and check the following: * The Python version is: Python3.10 from "C:\Users\21904\PycharmProjects\PythonProject\.venv\Scripts\python.exe" * The NumPy version is: "2.2.6" and make sure that they are the versions you expect. Please carefully study the documentation linked above for further help. Original error was: PyCapsule_Import could not import module "datetime"
最新发布
11-30
Traceback (most recent call last): File "D:\anaconda\envs\ai_env\lib\site-packages\numpy\core\__init__.py", line 23, in <module> from . import multiarray File "D:\anaconda\envs\ai_env\lib\site-packages\numpy\core\multiarray.py", line 10, in <module> from . import overrides File "D:\anaconda\envs\ai_env\lib\site-packages\numpy\core\overrides.py", line 6, in <module> from numpy.core._multiarray_umath import ( ModuleNotFoundError: No module named 'numpy.core._multiarray_umath' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "D:\pythonProject\pythonProject5\main.py", line 16, in <module> import tensorflow as tf File "D:\anaconda\envs\ai_env\lib\site-packages\tensorflow\__init__.py", line 37, in <module> from tensorflow.python.tools import module_util as _module_util File "D:\anaconda\envs\ai_env\lib\site-packages\tensorflow\python\__init__.py", line 37, in <module> from tensorflow.python.eager import context File "D:\anaconda\envs\ai_env\lib\site-packages\tensorflow\python\eager\context.py", line 26, in <module> import numpy as np File "D:\anaconda\envs\ai_env\lib\site-packages\numpy\__init__.py", line 140, in <module> from . import core File "D:\anaconda\envs\ai_env\lib\site-packages\numpy\core\__init__.py", line 49, in <module> raise ImportError(msg) ImportError: IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE! Importing the numpy C-extensions failed. This error can happen for many reasons, often due to issues with your setup or how NumPy was installed. We have compiled some common reasons and troubleshooting tips at: https://numpy.org/devdocs/user/troubleshooting-importerror.html Please note and check the following: * The Python version is: Python3.10 from "D:\anaconda\envs\ai_env\python.exe" * The NumPy version is: "1.23.5" and make sure that they are the versions you expect. Please carefully study the documentation linked above for further help. Original error was: No module named 'numpy.core._multiarray_umath' 进程已结束,退出代码1
07-25
C:\Users\Daccord\.conda\envs\TS\python.exe D:\Code\Text-Generate-RNN-master\train.py Traceback (most recent call last): File "C:\Users\Daccord\.conda\envs\TS\lib\site-packages\numpy\core\__init__.py", line 22, in <module> from . import multiarray File "C:\Users\Daccord\.conda\envs\TS\lib\site-packages\numpy\core\multiarray.py", line 12, in <module> from . import overrides File "C:\Users\Daccord\.conda\envs\TS\lib\site-packages\numpy\core\overrides.py", line 7, in <module> from numpy.core._multiarray_umath import ( ImportError: DLL load failed: 找不到指定的模块。 During handling of the above exception, another exception occurred: Traceback (most recent call last): File "D:\Code\Text-Generate-RNN-master\train.py", line 7, in <module> import tensorflow as tf File "C:\Users\Daccord\.conda\envs\TS\lib\site-packages\tensorflow\__init__.py", line 99, in <module> from tensorflow_core import * File "C:\Users\Daccord\.conda\envs\TS\lib\site-packages\tensorflow_core\__init__.py", line 28, in <module> from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import File "C:\Users\Daccord\.conda\envs\TS\lib\site-packages\tensorflow\__init__.py", line 50, in __getattr__ module = self._load() File "C:\Users\Daccord\.conda\envs\TS\lib\site-packages\tensorflow\__init__.py", line 44, in _load module = _importlib.import_module(self.__name__) File "C:\Users\Daccord\.conda\envs\TS\lib\importlib\__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "C:\Users\Daccord\.conda\envs\TS\lib\site-packages\tensorflow_core\python\__init__.py", line 47, in <module> import numpy as np File "C:\Users\Daccord\.conda\envs\TS\lib\site-packages\numpy\__init__.py", line 150, in <module> from . import core File "C:\Users\Daccord\.conda\envs\TS\lib\site-packages\numpy\core\__init__.py", line 48, in <module> raise ImportError(msg) ImportError: IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE! Importing the numpy C-extensions failed. This error can happen for many reasons, often due to issues with your setup or how NumPy was installed. We have compiled some common reasons and troubleshooting tips at: https://numpy.org/devdocs/user/troubleshooting-importerror.html Please note and check the following: * The Python version is: Python3.7 from "C:\Users\Daccord\.conda\envs\TS\python.exe" * The NumPy version is: "1.21.6" and make sure that they are the versions you expect. Please carefully study the documentation linked above for further help. Original error was: DLL load failed: 找不到指定的模块。
06-24
RuntimeError Traceback (most recent call last) RuntimeError: module compiled against API version 0xf but this version of numpy is 0xd --------------------------------------------------------------------------- ImportError Traceback (most recent call last) ImportError: numpy.core.multiarray failed to import The above exception was the direct cause of the following exception: SystemError Traceback (most recent call last) SystemError: <built-in method __contains__ of dict object at 0x00000270A8577F80> returned a result with an error set The above exception was the direct cause of the following exception: ImportError Traceback (most recent call last) <ipython-input-21-035b45420c6e> in <module> ----> 1 from model.build_mtcnn_model import create_Pnet, create_Rnet, create_Onet 2 import numpy as np 3 import cv2 4 5 ~\Desktop\第五课 实战案例:基于FaceNet的人脸智能识别 - 副本\(ppt、源代码、数据)数据&代码\数据&代码\基于FaceNet的人脸智能识别\model\build_mtcnn_model.py in <module> ----> 1 from tensorflow.keras.layers import Conv2D, Input, MaxPool2D, Flatten, Dense, Permute 2 from tensorflow.keras.layers import PReLU 3 from tensorflow.keras.models import Model 4 5 # -----------------------------# C:\StFiles\Anaconda\lib\site-packages\tensorflow\__init__.py in <module> 36 import typing as _typing 37 ---> 38 from tensorflow.python.tools import module_util as _module_util 39 from tensorflow.python.util.lazy_loader import LazyLoader as _LazyLoader 40 C:\StFiles\Anaconda\lib\site-packages\tensorflow\python\__init__.py in <module> 35 36 from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow ---> 37 from tensorflow.python.eager import context 38 39 # pylint: enable=wildcard-import C:\StFiles\Anaconda\lib\site-packages\tensorflow\python\eager\context.py in <module> 32 from tensorflow.python
03-29
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值