Forums

Unable to deploy on pythonanywhere because of KeyError

I've downloaded the pythonanywhere installation tool and am trying to deploy with the following line:

pa_autoconfigure_django.py <https://github.com/myusername/myproject.git>

Then, I get this a key error. My project runs on local.

    File "/projects/hosproject/venv/lib/python3.7/site-packages/pythonanywhere/project.py", line 16, in __init__
     self.virtualenv = Virtualenv(self.domain, self.python_version)
     File "/projects/hosproject/venv/lib/python3.7/site-packages/pythonanywhere/virtualenvs.py", line 12, in __init__
     self.path = Path(os.environ["WORKON_HOME"]) / domain
     File "/projects/hosproject/venv/bin/../lib/python3.7/os.py", line 678, in __getitem__
     raise KeyError(key) from None
      KeyError: 'WORKON_HOME'

Need some help to debug this and try to deploy again. If it helps, I'm new to Django and following this tutorial: https://tutorial.djangogirls.org/en/deploy/.

Help please, any hint will be helpful.

It looks like you might be running the PythonAnywhere tools from a terminal on your own machine -- you should run it in a bash console on PythonAnywhere -- you can start one from the "Consoles" page.

Thanks! This was it.

No problem, glad to help!

Yup..thanks it was helpful for me as well

thank you, it helped me

Glad to hear that!

When I tried at first, it was saying no modules found Now it was saying KeyError:Display. Can anyone pls explain throughly that I should need to do. I am a Begineer

import time
from selenium import webdriver
import pyautogui as chirag
from time import sleep
import schedule
def join():
    chrome_options = webdriver.ChromeOptions()
    prefs = {"profile.default_content_setting_values.notifications": 1,
             "profile.default_content_setting_values.media_stream_mic": 1,
             "profile.default_content_setting_values.media_stream_camera": 1,
             "profile.default_content_setting_values.geolocation": 2}
    chrome_options.add_experimental_option("prefs", prefs)
    driver = webdriver.Chrome(options=chrome_options)
    driver.get('https://accounts.google.com/')
    sleep(10)
    driver.maximize_window()
    driver.find_element_by_xpath('//*[@id="identifierId"]').send_keys('9211208@student.nitandhra.ac.in')
    chirag.press('enter')
    sleep(15)
    driver.find_element_by_xpath('//*[@id="password"]/div[1]/div/div[1]/input').send_keys("chirag@2000")
    chirag.press('enter')
    sleep(15)
    driver.get("https://meet.google.com/yrf-feui-ykz")
    sleep(20)
    chirag.hotkey('ctrl', 'd')
    sleep(3)
    chirag.hotkey('ctrl', 'e')
    sleep(3)
    driver.find_element_by_xpath('//*[@id="yDmH0d"]/c-wiz/div/div/div[9]/div[3]/div/div/div[3]/div/div/div[2]/div/div[2]/div/div[1]/div[1]/span').click()
    sleep(900)
    driver.find_element_by_xpath('//*[@id="ow3"]/div[1]/div/div[9]/div[3]/div[10]/div[2]/div/div[7]/span/button').click()
schedule.every().day.at("06:59").do(join)
while True:
    schedule.run_pending()
    time.sleep(5)

Could you try running our sample code from this help page and check if it works for you? If so, try adjusting the your code respectively. Mind that PythonAnywhere is a headless environment.

I am also getting this type of error saying

Traceback (most recent call last):   File "bot.py", line 3, in
<module>
     import mouseinfo   File "/home/Luckyklyist/.virtualenvs/myvirtualenv/lib/python3.6/site-packages/mouseinfo/__init__.py",
 line 223, in <module>
     _display = Display(os.environ['DISPLAY'])   File "/usr/local/lib/python3.6/os.py", line 669, in __getitem__
     raise KeyError(key) from None KeyError: 'DISPLAY

can anyone help me with it?

PythonAnyhwere is a headless environment, there is no DISPLAY.