Forums

Virtualenv not able to detect pip installed python modules

I'm am attempting to run a python script as a scheduled task however it includes the module webdriver-manager so I have setup a virtual environment to download additional modules. I am running the script initially in the console before setting up a scheduled task.

I am using a hashbang as advised in the help to define the virtualenv to use when running the script. However I cannot find the correct combination to use for the console to be able to see the module in order to run the code, I recieve the error: No module named 'webdriver_manager'.

I have installed webdriver-manager using pip and I can see it in the file structure within my virtual environment.

The hashbang I used is: #!/home/antmole/.virtualenvs/myvirtualenv/bin/python3.9

I can't see what I'm doing wrong... Can anyone advise on how I can "see" the required module?

What is the exact command of your scheduled task and what is the most recent error in the task's log? (You'd need to check the bottom of the log file.)

I am.not running it as a scheduled task yet. I am testing it as a standalone script in the console. The error I'm experiencing is to do with not seeing the module and my objective is to correctly use a hashbang for a virtual environment to see the module correctly.

Can you show the exact command you use in the console and the error you get?

See screenshot of error

See screenshot of error here:

https://freeimage.host/i/Fpx4FHJ

Could you click on the Run button and see if that helps? (Also: remember you're on Linux machine, so .exe files won't work here).

Yes that is the error after I’ve pressed run. And the line referencing an exe is hashed out - so I’m not using it.

I’ve managed to get around this console error by running it as a scheduled task. The hashbang works from there and I’ve installed all the modules I need, however now I’m facing new errors in the log. Ideally I’d want webdriver-manager to work. But I need I need to install chrome within my file structure for selenium to be able to open a chrome browser. Can you advise on how to do that?

You will not be able to install system-wide package on PythonAnywhere. You could try uploading a binary for chromedriver, for example, and pointing to it in your script.

PS. do you see the import errors when you run the script in a Bash console, not in the editor?