加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

python – Visual Studio代码没有看到wget

发布时间:2020-12-16 22:29:50 所属栏目:Python 来源:网络整理
导读:我在我的机器上安装了Python 2.7.我在Visual Studio Code(VSC)(MacOS发行版)中使用它没有问题,但我很难让Visual Studio Code“看到”wget. 在我的VSC中,我将以下import语句添加到myProject.py: import wget linter说这个: E0401:Unable to import wget 我

我在我的机器上安装了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  
最佳答案
我的Python安装有问题.我不确定它是什么或为什么,因为我安装的其他软件包工作正常(matplotlib等).

这是我如何解决它:

我通过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并且它工作正常.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读