您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

python – Visual Studio代码没有看到wget

5b51 2022/1/14 8:21:35 python 字数 3310 阅读 536 来源 www.jb51.cc/python

我在我的机器上安装了Python 2.7.我在Visual Studio Code(VSC)(MacOS发行版)中使用它没有问题,但我很难让Visual Studio Code“看到”wget.在我的VSC中,我将以下import语句添加到myProject.py:import wget linter说这个: E0401:Unable to import

概述

我在我的机器上安装了Python 2.7.我在Visual Studio Code(VSC)(MacOS发行版)中使用它没有问题,但我很难让Visual Studio Code“看到”wget.

在我的VSC中,我将以下import语句添加到myProject.py:

import wget

linter说这个:

E0401:Unable to import ‘wget’

我通过以下命令验证了我已安装wget:

which wget

…返回……

/usr/local/bin/wget

我试图用brew install wget重新安装它,但它说它已经安装了.所以我尝试了sudo -H pip install wget,我认为安装成功.

Collecting wget Downloading wget-3.2.zip Building wheels for
collected packages: wget Running setup.py bdist_wheel for wget …
done Stored in directory:
/var/root/Library/Caches/pip/wheels/6d/98/29/61ccc41148f871009126c2e844e26f73eeb25e12cca92228a5
Successfully built wget Installing collected packages: wget
Successfully installed wget-3.2

关闭VSC并重新打开它.我继续在linter中得到这个错误

E0401:Unable to import ‘wget’

我最近安装并卸载了anaconda,我很确定这是我痛苦的根源.我不经常使用Python,但我发现自己正在开发一个非常方便的项目.我没有想法:如何解决这个问题.我欢迎你的建议,谢谢你的阅读.

更新:

This question描述了我遇到的问题.我已经尝试了建议的解决方案,但它们似乎都没有摆脱我的linter错误.

更新我的.bash_profile似乎没有任何效果

export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python2.7/site-packages  

这是我如何解决它:

我通过home-brew卸载了python,如下所示:

brew卸载python

然后,我通过brew重新安装python如下:

brew安装python

我在终端中使用以下命令打开了我的.bash_profile:

打开.bash_profile

我在路径之前注释掉了并添加了这个路径(除非你确定你不需要它,否则不要去路径):

export PATH =“/usr/local/opt / python / libexec / bin:$PATH”

然后,我按照brew提示完成安装.完成后,我通过pip2安装了wget,如下所示:

pip2 install wget

之后,我打开了Visual Studio Code,键入import wget并且它工作正常.

总结

以上是编程之家为你收集整理的python – Visual Studio代码没有看到wget全部内容,希望文章能够帮你解决python – Visual Studio代码没有看到wget所遇到的程序开发问题。


如果您也喜欢它,动动您的小指点个赞吧

除非注明,文章均由 laddyq.com 整理发布,欢迎转载。

转载请注明:
链接:http://laddyq.com
来源:laddyq.com
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。


联系我
置顶