简体   繁体   English

我一直有 Traceback(最近一次调用最后一次):每次运行下面的 selenium 文件时出错。 我怎样才能解决这个问题?

[英]I keep having Traceback (most recent call last): error each time I run my selenium file below. How can I fix this?

I'm running a selenium file with the following code in python and I keep having a traceback call error.我在 python 中运行带有以下代码的 selenium 文件,并且我一直遇到回溯调用错误。 I can't tell what the problem is.我说不出问题是什么。 Below is the error I keep having:以下是我一直遇到的错误:

[Traceback (most recent call last): File "C:\Users\Whizzy.Ellah\PycharmProjects\virtual_assistant_final_year_project\selenium_web.py", line 2, in from selenium import webdriver File "C:\anacondaF\envs\finalYrProject\lib\site-packages\selenium\webdriver_init_.py", line 18, in from .firefox.webdriver import WebDriver as Firefox # noqa File "C:\anacondaF\envs\finalYrProject\lib\site-][1]Traceback (most recent call last):
  File "C:\Users\Whizzy.Ellah\PycharmProjects\virtual_assistant_final_year_project\selenium_web.py", line 2, in <module>
    from selenium import webdriver
  File "C:\anacondaF\envs\finalYrProject\lib\site-packages\selenium\webdriver\__init__.py", line 18, in <module>
    from .firefox.webdriver import WebDriver as Firefox  # noqa
  File "C:\anacondaF\envs\finalYrProject\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 26, in <module>
    from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver
  File "C:\anacondaF\envs\finalYrProject\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 40, in <module>
    from .remote_connection import RemoteConnection
  File "C:\anacondaF\envs\finalYrProject\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 26, in <module>
    import urllib3
ModuleNotFoundError: No module named 'urllib3'

Process finished with exit code 1

My code:我的代码:

import time
from selenium import webdriver
from selenium.webdriver import chrome

class web_driver_info():
    def __int__(self):
        self.driver = webdriver.Chrome(executable_path=r'C:\\Users\\Whizzy.Ellah\\PycharmProjects\\virtual_assistant_final_year_project\\chromedriver.exe')       

    def get_info(self, query):                 
        self.query = query                     
        self.driver.get(url='https://www.wikipedia.org')          


class_instance = web_driver_info()
class_instance.get_info("Hello")

Either urllib3 is not imported or not installed. urllib3 未导入或未安装。

To import, use要导入,请使用

import urllib3

at the top of the file.在文件的顶部。 To install write:要安装写入:

pip install urllib3

into terminal.进入终端。

Apart from the two reasons mentioned by @Ankit_Gunner in their answer that:除了@Ankit_Gunner在他们的回答中提到的两个原因之外:

Either urllib3 is not imported or not installed. urllib3 未导入或未安装。

There can be another possibility as follows:可能还有另一种可能性,如下所示:

  • urllib3 or requests module is backdated and needs a update. urllib3requests模块已过时,需要更新。

In that case you need to upgrade urllib3 / requests module as:在这种情况下,您需要将urllib3 / requests模块升级为:

  • Using pip :使用pip

     pip install --upgrade requests
  • Using pip3 :使用pip3

     pip3 install --upgrade requests

This is what finally worked for me这最终对我有用

I tried changing the virtual environment from anaconda to python virtual environment by deactivating the anaconda virtual env that is being used by typing conda deactivate finalYrProject (finalYrProject is the name of my virtual environment) through the anaconda command prompt. I tried changing the virtual environment from anaconda to python virtual environment by deactivating the anaconda virtual env that is being used by typing conda deactivate finalYrProject (finalYrProject is the name of my virtual environment) through the anaconda command prompt.

Also, I had to change the base interpreter - ie Python interpreter by clicking on the file tab in Pycharm > settings > Python interpreter > settings' icon near the already used python interpreter selected > Show All and selected from the list of Python interpreters I had. Also, I had to change the base interpreter - ie Python interpreter by clicking on the file tab in Pycharm > settings > Python interpreter > settings' icon near the already used python interpreter selected > Show All and selected from the list of Python interpreters I had . And after running the code again everything works fine.再次运行代码后一切正常。

暂无
暂无

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

相关问题 每次运行此代码时,我都会得到 Traceback(最近一次调用),如何解决这个问题? - I get Traceback (most recent call last) each time I run this code, how to fix this? 如何修复 Pulp 约束中的 Traceback(最近一次调用最后一次)错误 - How can I fix a Traceback (most recent call last) error in a Pulp constraint 为什么我会收到“回溯(最近一次呼叫最后一次):”错误? - Why am I getting a “ Traceback (most recent call last):” error? 我正在获取 Traceback Traceback(最近一次通话最后一次): - i am getting Traceback Traceback (most recent call last): 我可以逃避此错误回溯(最近一次通话是最近一次):“文件” <stdin> ”,第1行,在 <module> 档案“ <stdin> ”,第2行,在data_entry中 - can i escape this error Traceback (most recent call last): File “<stdin>”, line 1, in <module> File “<stdin>”, line 2, in data_entry 我如何摆脱这个错误:Traceback(最近一次调用最后一次):文件“<string> ",第 1 行,在<module>文件“C:\程序?</module></string> - How Do I get rid of this error:Traceback (most recent call last): File "<string>", line 1, in <module> File "C:\Program? 如何解决停止迭代错误? 我收到 Traceback(最近一次通话最后一次)错误 - How to solve stopiteration error? i got Traceback (most recent call last) error 当我尝试运行此Python程序时,出现回溯错误(最近一次调用最近)。 我想知道解决方案 - I get an error of traceback (most recent call last) when I try to run this Python program. I want to know the solution to this 当我启动这段代码时,我在 pygame 模块的代码中发现了错误 Traceback (last last call last) 的问题 - When I start this code, i found a problem with error Traceback (most recent call last) in my code with pygame module 我为什么要得到回溯(最近一次通话是最近一次): - Why am I getting a Traceback (most recent call last):
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM