1

I want to install Selenium so that I can run a script (that I wrote on my windows machine) on the ubuntu machine.

  1. When I type in python --version I get Python 3.4.3
  2. When I type in python3 --version I get Python 3.4.3
  3. When I type in python3.7 --version I get Python 3.7.0

Side question... how do I default python to version 3.7?

Now main problem. When I type python3.7 -m pip install --upgrade pip (something that I guess I need to do to install modules for python 3.7) I get error output:

Traceback (most recent call last):
  File "/usr/lib/python3.7/runpy.py", line 183, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/usr/lib/python3.7/runpy.py", line 142, in _get_module_details
    return _get_module_details(pkg_main_name, error)
  File "/usr/lib/python3.7/runpy.py", line 109, in _get_module_details
    __import__(pkg_name)
  File "/usr/lib/python3/dist-packages/pip/__init__.py", line 59, in <module>
    from pip.log import logger
  File "/usr/lib/python3/dist-packages/pip/log.py", line 9, in <module>
    import colorama, pkg_resources
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 668, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 638, in _load_backward_compatible
  File "/usr/share/python-wheels/setuptools-3.3-py2.py3-none-any.whl/pkg_resources.py", line 1479, in <module>
    register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'

Maybe I'm going about it totally the wrong way? My goals are:

  1. Default python to 3.7

  2. Install Selenium using pip for python 3.7

  3. Run a python script saved to a file

Questions I already found but didn't help:

LucasSeveryn
  • 5,684
  • 8
  • 36
  • 60

1 Answers1

0

One easy simple way to set python3.7 as default python is to add to your ~/.bashrc file the following alias:

alias python=python3.7 (and restart the shell!)

To install with python3.7 you should have pip3.7 in your system. If you can't find where it is located, check it with this command:

which python3.7

and add to your PATH variable the directory of pip3.7 by adding this to your .bashrc file as well:

export PATH=${PATH}:/path_to_your_python3.7/bin

Don't forget to restart the shell to apply all the modifications.

  • thanks Gonzalo, this switched the default python to 3.7, but I still am unable to install selenium – LucasSeveryn Nov 21 '19 at 16:53
  • both `pip install selenium` and `pip3 install selenium` behave as if default python was still 3.4. `Requirement already satisfied (use --upgrade to upgrade): selenium in /usr/local/lib/python3.4/dist-packages` – LucasSeveryn Nov 21 '19 at 16:55
  • Do you have pip3.7 in the console? – Gonzalo Recio Nov 21 '19 at 16:57
  • no, `pip3.7: command not found`. I'm not sure how am I even supposed to have it, it's not possible to install it via `sudo apt get install` command. – LucasSeveryn Nov 21 '19 at 16:59
  • Did you try [this](https://stackoverflow.com/questions/44761958/using-pip3-module-importlib-bootstrap-has-no-attribute-sourcefileloader)? – Gonzalo Recio Nov 21 '19 at 17:48
  • No module named ensurepip. – LucasSeveryn Nov 21 '19 at 18:05
  • Look at some of the comments below in [here](https://stackoverflow.com/questions/44761958/using-pip3-module-importlib-bootstrap-has-no-attribute-sourcefileloader), I remember having a similar problem and had to install in manually with a command like this: `curl -sS https://bootstrap.pypa.io/get-pip.py | python3.7` – Gonzalo Recio Nov 21 '19 at 18:25
  • doesn't work either.`AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'` – LucasSeveryn Nov 21 '19 at 18:43