Python can't find already installed module robobrowser

丶灬走出姿态 提交于 2019-12-08 06:27:51

问题


I am trying to create a very simple Python 3.6 script. Using MacOS.

For this script I had to install robobrowser, which I installed with easy_install robobrowser. After that I try to import it with the following statements:

import re
from robobrowser import RoboBrowser

However, terminal prompted me with the following (infamous) error:

Traceback (most recent call last):
  File "signup.py", line 2, in <module>
    from robobrowser import RoboBrowser
ModuleNotFoundError: No module named 'robobrowser'

I have installed Python 3.6. However, in my /Library/Python I only have 2 folders: 2.6 and 2.7. In /Library/Python/site-packages there is a folder named robobrowser-0.5.3-py2.7.egg. Might it have something to do with this?

Sorry for asking a most likely easy question. I can however not seem to figure it out.

Thanks for reading this,

Thijmen.


回答1:


Probably you are using easy_install for Python2. The best solution is to install pip for Python3 and run pip install robobrowser




回答2:


This must be because you have multiple versions of Python installed, and when you installed robobrowser, it got installed to a different python version than the one you are trying to use. If you want to use it with Python 3, make your $PATH variable use the Python3's Scripts path instead of the one from Python2. Or a simpler way is to install pip3 on your computer and do sudo pip3 install robobrowser

For reference: changing python path on mac?

You can run the which python, which python3 and which easy_install commands in your terminal to find which versions of python and easy_install are being used by default.



来源:https://stackoverflow.com/questions/46478207/python-cant-find-already-installed-module-robobrowser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!