简体   繁体   English

无法在 anaconda (Spyder) 中为 python 安装 googleads 模块

[英]Unable to install the googleads module for python in anaconda (Spyder)

I am trying to use the python googleads module in a script on Spyder.我正在尝试在 Spyder 的脚本中使用 python googleads 模块。

I have run pip install googleads and the installation has succeeded.我已经运行pip install googleads并且安装成功。

However, when I try to import googleads in the script on Spyder, it gives me the below error:但是,当我尝试在 Spyder 的脚本中import googleads时,出现以下错误:

ModuleNotFoundError: No module named 'googleads'

I have uninstalled the package and run pip install googleads again.我已经卸载了该软件包并再次运行pip install googleads The installation succeeds this time as well but the above error persists.这次安装也成功了,但上述错误仍然存​​在。

I have tried using conda install as well.我也尝试过使用 conda install 。 That does not install the package.那不会安装包。

However, when I run the script on the command prompt, it works fine.但是,当我在命令提示符下运行脚本时,它工作正常。 The issue is only with Spyder.问题仅在于 Spyder。

I have also Googled and looked up StackOverflow and most other communities for a solution to this but haven't been able to find one :(我也在谷歌上搜索并查找了 StackOverflow 和大多数其他社区的解决方案,但一直找不到:(

Looking forward to some help here, to fix the issue.期待在这里得到一些帮助,以解决问题。

Thank you in advance!先感谢您!

PS: I have run the pip install on the Anaconda prompt as well and that succeeds too. PS:我也在 Anaconda 提示符下运行了 pip install 并且也成功了。 The error on Spyder still exists. Spyder 上的错误仍然存​​在。

So I hired a freelancer with considerable experience in Anaconda and Spyder to help me fix this issue.所以我聘请了一位在 Anaconda 和 Spyder 方面具有丰富经验的自由职业者来帮助我解决这个问题。 Sharing the solution here for the benefit of everyone else.在这里分享解决方案以造福于其他所有人。

There was an issue with the installation of pip in the environment I was working in. This is how we found and fixed the issue:在我工作的环境中安装 pip 时出现问题。这是我们发现并解决问题的方法:

On the Anaconda prompt, we used the command conda list and checked if pip was installed.在 Anaconda 提示符下,我们使用命令conda list并检查是否安装了 pip。 It was.它是。

We then typed the command where pip and received the response below: C:\\Users\\Rohit\\AppData\\Local\\Programs\\Python\\Python37-32\\Scripts\\pip.exe然后我们输入命令where pip并收到以下响应:C:\\Users\\Rohit\\AppData\\Local\\Programs\\Python\\Python37-32\\Scripts\\pip.exe

We then created a new test environment in anaconda, navigated to it and ran the same where pip command.然后我们在 anaconda 中创建了一个新的测试环境,导航到它并运行相同的where pip命令。 It returned the below response: C:\\Users\\Rohit\\Anaconda3\\Scripts\\pip.exe C:\\Users\\Rohit\\AppData\\Local\\Programs\\Python\\Python37-32\\Scripts\\pip.exe它返回以下响应: C:\\Users\\Rohit\\Anaconda3\\Scripts\\pip.exe C:\\Users\\Rohit\\AppData\\Local\\Programs\\Python\\Python37-32\\Scripts\\pip.exe

We figured that there was an issue with the pip installation on the environment, which is why it was installing the packages on the global environment and not the project environment.我们认为环境上的 pip 安装存在问题,这就是为什么它在全局环境而不是项目环境中安装包的原因。

We then re-installed pip on the project environment using the conda install and re-ran the where pip command.然后我们使用 conda install 在项目环境中重新安装 pip 并重新运行where pip命令。 It now returned the below response: C:\\Users\\Rohit\\Anaconda3\\Scripts\\pip.exe C:\\Users\\Rohit\\AppData\\Local\\Programs\\Python\\Python37-32\\Scripts\\pip.exe它现在返回以下响应: C:\\Users\\Rohit\\Anaconda3\\Scripts\\pip.exe C:\\Users\\Rohit\\AppData\\Local\\Programs\\Python\\Python37-32\\Scripts\\pip.exe

After this, we installed the package using pip install googleads and then ran import googleads in Spyder.之后,我们使用pip install googleads安装包,然后在 Spyder 中运行import googleads It worked perfectly fine.它工作得很好。

Works fine now with all the other project packages.现在可以与所有其他项目包一起正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM