0

Newbie here, trying to import selenium. First time importing modules (outside of built-ins). My issue is whenever I pip3 install selenium it installs correctly to python 2.7.16 rather than 3.7.3. I found this out by running python3 in the terminal with no success importing selenium however just running the regular python can import selenium. More info:

  • I'm on macOS Catalina 10.15.4
  • I tried python3 -m pip install selenium based on a stack overflow response. When doing this, I receive the following error: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/Library/Python/3.7' Consider using the `--user` option or check the permissions. Not sure what this means but explanation greatly appreciated
  • Running which python returns /usr/bin/python
  • Running which python3 returns /usr/bin/python3
  • In Finder, /Library/Python only has the folder "2.7", doesn't have a "3.7"

Let me know if there is anything else I can do or any more information you need from me. Thanks in advance!

Rohan Shah
  • 479
  • 3
  • 14

2 Answers2

1

After scouring the internet I managed to put 2 answers together for the issue I was having. If you have a similar issue, use the command python3 -m pip install --user (your module) and it works like a charm. For more information, visit this GitHub issue which is where I got most of my answers to see if you need something similar. Hope this helps someone!

Rohan Shah
  • 479
  • 3
  • 14
  • Also, for those using Jupyter Notebook (via Anaconda Navigator for me but I'm not sure if it matters), it will save you a ton of time and trouble if you run your pip commands directly from the notebook. Don't use pip3, just regular `pip install module name` – Rohan Shah Apr 10 '20 at 20:40
0

Try searching how to change default python version to python3. I would recommend looking at this answer. The reason is that by default pip installs all packages to python2.7, the default system version. If you are using a virtualenv try initializing you virtualenv with python3 -m venv venv and then try pip install 'ModuleName'.

  • Thanks for the suggestion but after reading the responses, it seems changing the default version is highly unrecommended as (from what I understand) many programs expect the default python2 and explicitly changing it to python3 could break them. Ultimately I just want pip3 to install modules directly to python3 – Rohan Shah Apr 10 '20 at 18:04
  • Well, in your scenario you might want to try that, as I had the same issue. Which was resolved after changing default version. You can also just create an alias to python3 in your terminal which wont damage anything. You can also try initializing the virtualenv as I displayed in my answer. Then you can just use regular pip install to install your module. –  Apr 10 '20 at 18:10
  • Enter the bash_profile with, vi ~/.bash_profile. Then, type alias python='/usr/local/bin/python3' in the bash_profile. Then reload the bash_profile with, source ~/.bash_profile. Then reload the terminal and try pip install again. –  Apr 10 '20 at 19:06