ImportError: cannot import name 'RoboBrowser' from 'robobrowser' - python-3.7

I am very new to Python and have used BeautifulSoup to parse and scrape information from some webpages. Now I need to fill out a form. submit it, and scrape some data after filling in the form, and it seems the easiest way is to use robobrowser.
However, I can't import robobrowser. I have installed robobrowser several different ways and robobrowser is located here:
C:\Users\(USERNAME)\AppData\Local\Programs\Python\Python37-32\Lib\site-packages
Here is my script:
import requests
from bs4 import BeautifulSoup
import datetime
import webbrowser
import re
from robobrowser import RoboBrowser
br = RoboBrowser()
etc....
The problem is the script will not run past "from robobrowser import RoboBrowser" and I get the following message:
ImportError: cannot import name 'RoboBrowser' from 'robobrowser'

Maybe your robobrowser package is corrupted
Now try Installing robobrowser using PyPI
first check if python package named as PyPI is installed on your system using this command in your terminal
pip --version
if it is installed then it will show the output like that
To install robobrowser using PyPI run this command in your terminal
pip install robobrowser
now import it
from robobrowser import RoboBrowser
br = RoboBrowser()

Related

empty __init__.py file with error " ImportError: cannot import name 'PILLOW_VERSION' from 'PIL' " when importing torchvision on M1

I have a functioning PyTorch installation with a conda environment with MPS backend working fine on a M1 mac.
However, after installing torchvision, when I try to import torchvision, I get this error (also shown in screenshot):
ImportError: cannot import name 'PILLOW_VERSION' from 'PIL' (/opt/anaconda3/lib/python3.9/site-packages/PIL/__init__.py)
In the screenshot below, I run python in my terminal and then try to import torchvision and get the error.
I have navigated to and opened the file in question __init__.pyin the PIL folder, and the file itself is empty.
If relevant:
torch version is 1.13.0.dev20220911
Python is 3.9.13
Conda is 22.9.0
I have tried installing and reinstalling with conda and pip multiple times but with the same result when importing torchvision.
I found this stackoverflow question about PILLOW_version, which got me to try to rename the __init__.py file that turned out to be empty, which I did not expect, since that made it impossible to rename the pillow versioning.
Thanks in advance.

I've installed pillow and can't import it into the python shell

I've looked over 30 different pages and couldn't find the answer I needed. I'm using a windows 10 and I'm using python 3.9.0. So I installed Pillow 8.1.0 like this:
python3 -m pip install --upgrade Pillow
Then tried to import pillow into the shell using:
import PIL
import Pillow
import pillow
from Pillow import Image
from PIL import Image
from PIL import *
from Pillow import *
but I got the ModuleNotFoundError every time.
Do you have another way to put pillow into the python shell?
Thanks for the answer in advance😄.
If you're still having trouble, try this:
in your python terminal run:
import sys
print(f'"{sys.executable}" -m pip install pillow')
print(f'"{sys.executable}" -m pip install requests')
then, with the printouts you get, run your windows command prompt as an admin (right click -> run as admin) then paste the 2 commands you get back. restart python and you SHOULD be good to go.
With python 3.9 and above using Pillow 8.1.0, use
from pil import Image.

ImportError: cannot import name 'StopLocust' from 'locust.exception'

I'm getting an ImportError attempting to run a Locust/Selenium script: ImportError: cannot import name 'StopLocust' from 'locust.exception'
Is there a package that I need to install?
from realbrowserlocusts import ChromeLocust
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from locust_plugins.users import WebdriverUser
from locust.exception import StopLocust
import os
from locust import TaskSet, task
The output from the Terminal window shows this:
File "c:\users\mjohns33\pycharmprojects\omni\lib\site-packages\realbrowserlocusts\core.py", line 6, in
from locust.exception import StopLocust
ImportError: cannot import name 'StopLocust' from 'locust.exception' (c:\users\mjohns33\pycharmprojects\omni\lib\site-packages\locust\exception.py)
Any ideas?
If you're using Locust 1.0+ there is no StopLocust in locust.exceptions. I'm not sure what it is you're looking to do so I don't know if it's the right thing for you to use, but there is StopUser in there that you should be able to import.
Local environment issue. Re-installing my setup.
After doing some more research I was able to resolve a couple of issues from the import error. Installing locustio solved the import issue and a follow-on issue in attempting to load the locust web page was solved by updating gevent.
So, for the full fix uninstall the current version of locust and install the locustio version. Then upgrade the gevent.
pip uninstall locust
pip install locustio==0.14.6
pip install --upgrade gevent
Realbrowserlocusts isn't compatible with the most recent versions of Locust. Downgrading to version locust 0.13.5 fixed the issue. I'm not sure exactly which of the most recent versions of locust supports realbrowserlocusts. I would like to find out though so I'm running the best of locust versions supporting running with selenium.

Python pillow module not importing properly

I'm using the Python pillow module, but every time I try to import it and use a function, it gives me an error. Here is some code to reproduce the error.
import PIL
PIL.ImageGrab.grab()
You have to use from to import from PIL.
from PIL import ImageGrab
ImageGrab.grab()

No module named 'scipy', although installed with Anaconda. Python 3 on Windows 10

I did conda install for numpy, pandas, scipy, and scikit-learn apparently all successful. I also tried to change the path in the Windows 10 registry. I only have 1 version of Python, 3.6 installed. I also installed Visual Studio. If I run the script, I get "scipy module not found". Can you explain me what's the problem, and how to fix this?
My imports look like this:
import pandas as pd
import quandl, math
import numpy as np
from sklearn import preprocessing, cross_validation, svm
from sklearn.linear_model import LinearRegression
I'm following this tutorial by Sentdex:
https://www.youtube.com/watch?v=r4mwkS2T9aI&index=4&list=PLQVvvaa0QuDfKTOs3Keq_kaG2P55YRn5v