Forums

Python runs with '/usr/local/lib/python2.7' not with my virtual env

I ran 'virtualenv --python=python3.4 myenv' and I checked the python version of myenv is 3.4 by running 'python -V'.

My pip version is also 3.4 checked by the same way.

I set my virtualenv in 'WEB' section : /home/LeeKyungMoon/myenv/

But when my scheduled python file is ran, it shows me the error with python 2.7 : 'selenium.common.exceptions.WebDriverException: Message: u'unknown error: Chrome failed to start: crashed\n (Driver info: chromedriver=2.23.409687,platform=Linux 3.13.0-91-generic x86_64)'

How can I run this file with python 3.4?

The virtualenv you specify in the "Web" section of PythonAnywhere only affects that specific web app, so that you can have different virtualenvs for different websites.

If you want to specify a particular virtualenv for a scheduled task, you can specify it by adding it to the start of the command that's run for that scheduled task. For example, if you want /home/LeeKyungMoon/myscript.py to be run with the virtualenv in /home/LeeKyungMoon/myenv/, then you schedule a command like this:

/home/LeeKyungMoon/myenv/bin/python /home/LeeKyungMoon/myscript.py