aax2mp3-easy icon indicating copy to clipboard operation
aax2mp3-easy copied to clipboard

On running script >> ModuleNotFoundError: No module named 'selenium'

Open Caruso33 opened this issue 7 years ago • 29 comments

Output of Bash:

Installing collected packages: selenium
Successfully installed selenium-3.8.0
Traceback (most recent call last):
  File "audible-activator-feature_login_as_arg/audible-activator.py", line 8, in <module>
    from selenium import webdriver
ModuleNotFoundError: No module named 'selenium'

Any suggestions why the import from selenium no longer works?

Caruso33 avatar Dec 15 '17 07:12 Caruso33

I'll try to check that for you as soon as possible, but can you describe what's your environment?

paladini avatar Dec 18 '17 22:12 paladini

I've just set up a new Ubuntu 17.10 environment. The error remains.

Caruso33 avatar Dec 21 '17 02:12 Caruso33

Same issue here on Manjaro (Arch based)

Trophonix avatar Dec 22 '17 02:12 Trophonix

I had also some issues with the installation (Ubuntu 16.04), getting the same error, however due to another issue;

sudo: pip: command not found
sudo: pip: command not found
Traceback (most recent call last):
  File "audible-activator-feature_login_as_arg/audible-activator.py", line 8, in <module>
    from selenium import webdriver
ImportError: No module named selenium

This could be solved by installation of python-setuptools and python easy_install pip. But I also had to reinstall aax2mp3-easy to make in work properly. So if selenium and chromium runs otherwise for you, a reinstall of the tool may help.

dagmarkrefting avatar Jan 01 '18 12:01 dagmarkrefting

Hey guys, try to install Selenium running one of the following commands:

pip install selenium

or

sudo pip install selenium

Can you tell me the output for AAX2MP3-easy after running one of these commands?

paladini avatar Jan 03 '18 23:01 paladini

audible-activator.py works well, it stops to work when runned from aax2mp3

EDIT: ./aax2mp3_easy.sh <user> <pass> <file> first run output tail is:

Requirement already satisfied: requests in /usr/local/lib/python2.7/dist-packages 
Requirement already satisfied: selenium in /usr/local/lib/python2.7/dist-packages
Traceback (most recent call last):
  File "audible-activator-feature_login_as_arg/audible-activator.py", line 8, in <module>
    from selenium import webdriver
ModuleNotFoundError: No module named 'selenium' 

sudo ./aax2mp3_easy.sh <user> <pass> <file> first run output tail is:

Requirement already satisfied: requests in /usr/local/lib/python2.7/dist-packages
Requirement already satisfied: selenium in /usr/local/lib/python2.7/dist-packages
Traceback (most recent call last):
File "audible-activator-feature_login_as_arg/audible-activator.py", line 148, in
fetch_activation_bytes(username, password, options)
File "audible-activator-feature_login_as_arg/audible-activator.py", line 57, in fetch_activation_bytes
executable_path=chromedriver_path)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/chrome/webdriver.py", line 75, in init
desired_capabilities=desired_capabilities)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 154, in init
self.start_session(desired_capabilities, browser_profile)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 243, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 312, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally
(Driver info: chromedriver=2.35.528139 (47ead77cb35ad2a9a83248b292151462a66cd881),platform=Linux 4.9.0-6-amd64 x86_64)

2018-03-03 02:19:06+0100 Decoding Player with auth code [*]...

Obviously no updates on both attempts

nikoroxy avatar Mar 03 '18 01:03 nikoroxy

I attempted to use this on my Macbook and got the same result as @nikoroxy

Trophonix avatar Apr 11 '18 18:04 Trophonix

So I had the same issue as you guys. (Ubuntu 16.04 LTS)

As @dagmarkrefting suggested I installed python-setuptools and python easy_install pip. After that I could install, as @paladini wrote, Selenium. This still gave the the error:

Traceback (most recent call last):
  File "audible-activator-feature_login_as_arg/audible-activator.py", line 148, in <module>
    fetch_activation_bytes(username, password, options)
  File "audible-activator-feature_login_as_arg/audible-activator.py", line 57, in fetch_activation_bytes
    executable_path=chromedriver_path)
  File "/home/USERNAME/.local/lib/python2.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 75, in __init__
    desired_capabilities=desired_capabilities)
  File "/home/USERNAME/.local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 154, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "/home/USERNAME/.local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 243, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/home/USERNAME/.local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 312, in execute
    self.error_handler.check_response(response)
  File "/home/USERNAME/.local/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary
  (Driver info: chromedriver=2.37.544315 (730aa6a5fdba159ac9f4c1e8cbc59bf1b5ce12b7),platform=Linux 4.4.0-119-generic x86_64)

After that I tried it step by step with audible-activator.py and AAXtoMP3 (which were automatically installed) according to code.opoki.com/.... Got a similar error in the first step. Then I realized that it was simply looking for Chrome.

[Solution] I installed Chrome and it worked.

Not only did it work in the manual 2 step variant but also this scripted worked :) I hope this will solve your problems too. Maye just adding a part where it checks if Chrome is installed?

Thank you for this awesome script :D

birawaich avatar Apr 15 '18 15:04 birawaich

Hi Guys,

You need to specify the version of pip as it is wanting to install python3 version by default:

pip2 install selenium

or in my case to avoid error messages running sudo:

sudo -H pip2 install selenium

I believe this will resolve the issue.

hexdream avatar May 25 '18 09:05 hexdream

@hexdream 's solution worked for me.

However, the script exits after opening chrome with ERROR Missing authcode.

cargocultprogramming avatar Aug 29 '18 11:08 cargocultprogramming

from selenium import webdriver ModuleNotFoundError: No module named 'selenium'

I am getting the above error, I have installed pip install -U selenium. Any suggestions to get this resolved

Sunildevbasavatti avatar Sep 04 '18 16:09 Sunildevbasavatti

from selenium import webdriver ModuleNotFoundError: No module named 'selenium'

I am getting the above error, I have installed pip install -U selenium. Any suggestions to get this resolved

i have same issue! i have installed selenium via pip3 and checked it but i still get this error dont know why

imansh77 avatar Oct 21 '18 19:10 imansh77

from selenium import webdriver ModuleNotFoundError: No module named 'selenium' I am getting the above error, I have installed pip install -U selenium. Any suggestions to get this resolved

i have same issue! i have installed selenium via pip3 and checked it but i still get this error dont know why

got same problem on my head !

write4alive avatar Nov 12 '18 13:11 write4alive

Hey guys, just to tell you that I'm going to check with the developer from Selenium about that issue. Seems to be something related to the lib.

paladini avatar Nov 28 '18 19:11 paladini

I use MAC and I have selenium working fine with python 3.7 from pycharm, but when I run the same python code from local Jenkins / slack (bot/snippet run) it gives me the same error as you guys are discussing, some help here is appreciated please, thank you.

"Import Error : No module named selenium"

shyamkumar0707 avatar Dec 05 '18 13:12 shyamkumar0707

Hi Guys,

little premise: unfortunately for me, I am not a CS student. But I am learning on my own and luckily Github and Stackflow communities are very helpful. Thus, I would like to say that I have already tried almost all the online suggestions I have found to solve previusly my issue (such as easy_install / sudo pip install / pip install...)

yet, this error message is still shown:

Isabellas-Air:instagram-profilecrawl isabellabocchese$ python3.6 crawl_profile.py ibocchese Traceback (most recent call last): File "crawl_profile.py", line 5, in from util.datasaver import Datasaver File "/Users/isabellabocchese/instagram-profilecrawl/util/datasaver.py", line 5, in from .util import check_folder File "/Users/isabellabocchese/instagram-profilecrawl/util/util.py", line 1, in from selenium.common.exceptions import NoSuchElementException ModuleNotFoundError: No module named 'selenium' Isabellas-Air:instagram-profilecrawl isabellabocchese$

AND

Isabellas-Air:instagram-profilecrawl isabellabocchese$ pip install exceptions selenium Collecting exceptions Could not find a version that satisfies the requirement exceptions (from versions: ) No matching distribution found for exceptions Isabellas-Air:instagram-profilecrawl isabellabocchese$ easy_install exceptions selenium Searching for exceptions Reading https://pypi.python.org/simple/exceptions/ Download error on https://pypi.python.org/simple/exceptions/: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:661) -- Some packages may not be found! Couldn't find index page for 'exceptions' (maybe misspelled?) Scanning index of all packages (this may take a while) Reading https://pypi.python.org/simple/ Download error on https://pypi.python.org/simple/: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:661) -- Some packages may not be found! No local packages or working download links found for exceptions error: Could not find suitable distribution for Requirement.parse('exceptions')

Any suggestions ? ;) thank you !!

iBocchese avatar Dec 21 '18 11:12 iBocchese

same here on mac, python 3.7 selenium 3.141.0 I can run at the very first time after successfully install selenium, but fail on it a day after with error " from selenium import webdriver ImportError: No module named selenium" any idea? many thanks

vivienzou1 avatar Jan 14 '19 18:01 vivienzou1

" from selenium import webdriver ImportError: No module named selenium" Same issue :(

Ilya88Weber avatar Jan 23 '19 16:01 Ilya88Weber

Traceback (most recent call last): File "quickstart.py", line 3, in from instapy import InstaPy File "/home/alkalin/Desktop/InstaPy/instapy/init.py", line 3, in from .instapy import InstaPy File "/home/alkalin/Desktop/InstaPy/instapy/instapy.py", line 12, in from selenium import webdriver ModuleNotFoundError: No module named 'selenium'

i already installed selenium and pip and pip2 and pip3 but nothing can be imported.

esalkan avatar Jan 30 '19 15:01 esalkan

I got the same problem. im new to programming and i read a lot about that error now and ive done everything i could. It says its already installed but it wont let me import webdrivers from slenium. C:\Users\timok\PycharmProjects\FirstSeleniumTest>pip install selenium Requirement already satisfied: selenium in c:\users\timok\appdata\local\programs\python\python37-32\lib\site-packages (3.141.0) Requirement already satisfied: urllib3 in c:\users\timok\appdata\local\programs\python\python37-32\lib\site-packages (from selenium) (1.24.1)

Hope i get help here

timo-x30xe avatar Feb 17 '19 13:02 timo-x30xe

Same problem, but on VS code. Solution found here: https://askubuntu.com/questions/1130323/importerror-no-module-named-selenium?rq=1

Open a command prompt and type "python3". When you get the python prompt, type "import Selenium" and see what error (if any) you get. It sounds like VS is running a separate python environment.

Seems we need to check the version if the python interpreter selected is of the same environment as the python with selenium installed.

superpigsam avatar Apr 20 '19 12:04 superpigsam

Please try specify the python directory:

The code works for me (Execute shell) command: /Users/Username/anaconda2/bin/python text.py

(My environment: Jenkins in local mac, py code in local )

wenyiyan avatar Jun 05 '19 23:06 wenyiyan

Using python2 worked for me, install pip2 (i.e sudo apt install python-pip), then pip2 install selenium and pip2 install requests (you need this one too). Also, install chrome lol.

pfabreu avatar Jul 25 '19 17:07 pfabreu

Heh, the above, @pedro-abreu -s actually worked. did pip install selenium on py2, still ImportError. Using pip2 explicitly fixed it.

tanel3203 avatar Aug 04 '19 20:08 tanel3203

I solved it going to "base" environment and installing selenium there too (I was trying to uso on "pytorch1" environment): conda activate base conda install -c conda-forge selenium

After turn back to "pytorch1", ... conda activate pytorch1

Every thing ok. Don't ask me why. :-)

eduamf avatar Aug 23 '19 19:08 eduamf

well... this is crazy I have the same issue with selenium package a few days ago it worked properly (I don't know how) but I was running the program today and the error comes up again and I tried several things but still have a problem

parisimaa avatar Mar 19 '20 09:03 parisimaa

To fix this problem - you need (Example is for windows, do the same for your system accordingly):

  1. Go to the subdirectory \Lib\site-packages\ of the installed Python environment directory (for example, if Python was installed on the C: drive in the Python directory, then go to c:\Python\Lib\site-packages)
  2. Find the [selenium] catalog in it. If there is no [selenium] but exists, for example, [selenium-3.141.0.dist-info], you need to delete all directories containing "selenium"
  3. Run the console (Win + R-> cmd.exe-> Enter) Run the selenium installation command again: pip install selenium
  4. Make sure the [selenium] directory appears in \Lib\site-packages\

gitwiserabbit avatar Mar 25 '20 12:03 gitwiserabbit

Helllllllpppppppppppppppp

File "C:\Users\Windows\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 38 str = basestring ^ IndentationError: unexpected indent

Someone help me?

paulolamorea avatar Apr 06 '20 22:04 paulolamorea