pydev Unresolved import

pydev是一个很好的开发工具,总有一个问题让我很头痛,使用第三方库的时候,总是会提示
Unresolved import,以 import MySQLdb为例,在python命令行输入:import MySQLdb 确认了安装成功后,使用pydev 还是会报Unresolved import。
就需要给PyDev添加支持:
打开:windows->Preferences->PyDev->Interpreter - Python
在Forced Builtins下面手工添加 MySQLdb 字段 强制编译。
Apply之后,可以看到 Libraries 下面添加了 MySQLdb的目录。如果没有,则手工在Libraries 下面添加MySQLdb的目录,再次强制编译即可。
但在装wxPython2.9-win32-py27 时, import wx 使用了上述方法后仍报错,原因是在安装wx2.9时,目录为Python27\Lib\site-packages\*wxPython2.9-msi*\wx; 只要把wx越过他的上级目录,直接放在site-packages下就可以解决问题了。
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'
最新发布
07-10
rom tensorflow.keras.preprocessing.sequence import pad_sequences Traceback (most recent call last): File "<input>", line 1, in <module> File "C:\Program Files\JetBrains\PyCharm 2021.1.3\plugins\python\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import module = self._system_import(name, *args, **kwargs) File "C:\Program Files\Python310\lib\site-packages\keras\api\_v2\keras\__init__.py", line 13, in <module> from keras.api._v2.keras import __internal__ File "C:\Program Files\JetBrains\PyCharm 2021.1.3\plugins\python\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import module = self._system_import(name, *args, **kwargs) File "C:\Program Files\Python310\lib\site-packages\keras\api\__init__.py", line 8, in <module> from keras.api import keras File "C:\Program Files\JetBrains\PyCharm 2021.1.3\plugins\python\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import module = self._system_import(name, *args, **kwargs) File "C:\Program Files\Python310\lib\site-packages\keras\api\keras\__init__.py", line 13, in <module> from keras.api.keras import __internal__ File "C:\Program Files\JetBrains\PyCharm 2021.1.3\plugins\python\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import module = self._system_import(name, *args, **kwargs) File "C:\Program Files\Python310\lib\site-packages\keras\api\keras\__internal__\__init__.py", line 10, in <module> from keras.saving.serialization_lib import enable_unsafe_deserialization File "C:\Program Files\JetBrains\PyCharm 2021.1.3\plugins\python\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import module = self._system_import(name, *args, **kwargs) File "C:\Program Files\Python310\lib\site-packages\keras\saving\serialization_lib.py", line 28, in <module> from keras.saving.legacy.saved_model.utils import in_tf_saved_model_scope ImportError: cannot import name 'in_tf_saved_model_scope' from 'keras.saving.legacy.saved_model.utils' (C:\Program Files\Python310\lib\site-packages\keras\saving\legacy\saved_model\utils.py)
06-01
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值