module = self._system_import(name, *args, **kwargs) ModuleNotFoundError: No module named 'pymysql'
时间: 2023-08-17 08:08:04 浏览: 243
这个错误通常是因为你的 Python 环境中缺少 `pymysql` 模块导致的。你可以通过以下命令安装:
```
pip install pymysql
```
如果你使用的是虚拟环境,请确保你已经激活了虚拟环境,并且在虚拟环境下安装了 `pymysql` 模块。
相关问题
Traceback (most recent call last): File "D:\Anaconda\lib\site-packages\IPython\core\interactiveshell.py", line 3369, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "<ipython-input-6-b8424bd64091>", line 2, in <cell line: 2> import torchvision File "D:\Pycharm\PyCharm Community Edition 2022.1.3\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import module = self._system_import(name, *args, **kwargs) File "D:\Anaconda\lib\site-packages\torchvision\__init__.py", line 6, in <module> from torchvision import datasets, io, models, ops, transforms, utils File "D:\Pycharm\PyCharm Community Edition 2022.1.3\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import module = self._system_import(name, *args, **kwargs) File "D:\Anaconda\lib\site-packages\torchvision\models\__init__.py", line 17, in <module> from . import detection, optical_flow, quantization, segmentation, video File "D:\Pycharm\PyCharm Community Edition 2022.1.3\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import module = self._system_import(name, *args, **kwargs) File "D:\Anaconda\lib\site-packages\torchvision\models\quantization\__init__.py", line 3, in <module> from .mobilenet import * File "D:\Pycharm\PyCharm Community Edition 2022.1.3\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import module = self._system_import(name, *args, **kwargs) File "D:\Anaconda\lib\site-packages\torchvision\models\quantization\mobilenet.py", line 1, in <module> from .mobilenetv2 import * # noqa: F401, F403 File "D:\Pycharm\PyCharm Community Edition 2022.1.3\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import module = self._system_import(name, *args, **kwargs) File "D:\Anaconda\lib\site-packages\torchvision\models\quantization\mobilenetv2.py", line 5, in <module> from torch.ao.quantization import DeQuantStub, QuantStub File "D:\Pycharm\PyCharm Community Edition 2022.1.3\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import module = self._system_import(name, *args, **kwargs) ModuleNotFoundError: No module named 'torch.ao.quantization'
这个错误通常是因为 torchvision 的版本与你安装的 torch 版本不兼容导致的。请尝试通过升级 torchvision 来解决此问题。可以使用以下命令升级 torchvision:
```
pip install --upgrade torchvision
```
这将安装 torchvision 的最新版本,其中包含了与你安装的最新 torch 版本兼容的功能和修复。如果问题仍然存在,请确保你安装的 torch 和 torchvision 版本是兼容的,并且与你的 Python 版本相匹配。希望这能解决你的问题!如果还有其他问题,请随时提问。
module = self._system_import(name, *args, **kwargs)
module = self._system_import(name, *args, **kwargs) 的意思是:通过系统导入模块,将其赋值给变量 module。其中,name 是要导入的模块名,*args 和 **kwargs 是传递给导入函数的参数。
阅读全文