kiyoon / jupynium.nvim

Selenium-automated Jupyter Notebook that is synchronised with NeoVim in real-time.
MIT License
509 stars 15 forks source link

Selenium Timeout Exception on NixOS #27

Closed fabian-gubler closed 1 year ago

fabian-gubler commented 1 year ago

Describe the bug TimeOutException after severeal seconds when running jupynium. After attaching the Server firefox is successfully opened, and selenium red bar is active. I think this could be an issue because of running it on NixOS and its filesystem.

To Reproduce Steps to reproduce the behavior:

  1. Create conda environment
  2. Install jupynium and dependencies with pip (using requirments.txt)
  3. Run nvim with listen and run jupynium according to README instructions
  4. AttachToServer
  5. See error

Expected behavior Able to use plugin...

Output when using jupynium command

timeout

Output of jupynium --version

Jupynium v0.1.1.dev44+g26e79c8

Output of nvim --version

NVIM v0.8.1

Additional context Copied selenium and pkgbuild libraries from python3.10 conda environment folder into python3.9 system folder. Otherwise the following error message: image

When importing selenium in conda environment, it works fine: image

fabian-gubler commented 1 year ago

Very cool plugin idea, have been wanting to use something look that for a long time. Thanks a lot for you investing the time to develop it!

kiyoon commented 1 year ago

Hi, I think the selenium is not installed correctly. You need to make sure this python code runs in your environment.

from selenium import webdriver
driver = webdriver.Firefox()
driver.get("https://www.selenium.dev/selenium/web/web-form.html")

If not, I think the fact that you had to manually copy the selenium files tells me that it's not installed correctly.

Make sure you're in the right conda environment and try installing again.

conda deactivate
conda activate jupynium
cd ~/path/to/jupynium.nvim
pip3 install -e .

Or, you can try just installing jupynium with your system python.

conda deactivate
pip3 install --upgrade pip
cd ~/path/to/jupynium.nvim
pip3 install -e .
fabian-gubler commented 1 year ago

Hello, thank you very much for the quick reply.

Running your python code snippet does not work in my environment. As a result, I think i might have found where the issue stems from.

When I run it, I receive the following output

FileNotFoundError: [Errno 2] No such file or directory: '/home/fabian/.dotfiles/shells/python/pip/.venv/lib/python3.10/site-packages/selenium/webdriver/common/linux/selenium-manager'

However, this file exists and is a binary. I am relatively new to NixOS (~ 1 week), but am almost certain that it cannot run this binary without some extra steps.

I might try it out another time and troubleshoot and come back to you with more information. I will tell you if I have found a solution so that other users running NixOS can use this plugin aswell.

Enjoy your weekend.

kiyoon commented 1 year ago

I have no idea how to use NixOS either, but I found this:
https://www.reddit.com/r/NixOS/comments/v7bpw9/how_shall_i_install_a_python_librarymodule/

nix-shell -p python3Packages.selenium

fabian-gubler commented 1 year ago

Using your suggestion, I could now run your selenium python code snippet from above (web form pops up).

When running jupynium I receive the following:

FileNotFoundError: [Errno 2] No such file or directory: '/nix/store/3mm8m3izk6hi7i4p22wrbp3id0202g2a-python3.10-selenium-4.6.0/lib/python3.10/site-packages/selenium/webdriver/firefox/webdriver_prefs.json'

Yes, this file indeed does not exist. I think that this file might not be included in version 4.6, you are using a more recent one (4.7.2).

fabian-gubler commented 1 year ago

There are ways to change package descriptions, in order to download newer versions. I will have a look at it over the weekends and get back to you.

kiyoon commented 1 year ago

What happens if you just download the prefs file from the internet?

I have this on my system:

{
  "frozen": {
    "app.update.auto": false,
    "app.update.enabled": false,
    "browser.displayedE10SNotice": 4,
    "browser.download.manager.showWhenStarting": false,
    "browser.EULA.override": true,
    "browser.EULA.3.accepted": true,
    "browser.link.open_external": 2,
    "browser.link.open_newwindow": 2,
    "browser.offline": false,
    "browser.reader.detectedFirstArticle": true,
    "browser.safebrowsing.enabled": false,
    "browser.safebrowsing.malware.enabled": false,
    "browser.search.update": false,
    "browser.selfsupport.url" : "",
    "browser.sessionstore.resume_from_crash": false,
    "browser.shell.checkDefaultBrowser": false,
    "browser.tabs.warnOnClose": false,
    "browser.tabs.warnOnOpen": false,
    "datareporting.healthreport.service.enabled": false,
    "datareporting.healthreport.uploadEnabled": false,
    "datareporting.healthreport.service.firstRun": false,
    "datareporting.healthreport.logging.consoleEnabled": false,
    "datareporting.policy.dataSubmissionEnabled": false,
    "datareporting.policy.dataSubmissionPolicyAccepted": false,
    "devtools.errorconsole.enabled": true,
    "dom.disable_open_during_load": false,
    "extensions.autoDisableScopes": 10,
    "extensions.blocklist.enabled": false,
    "extensions.checkCompatibility.nightly": false,
    "extensions.update.enabled": false,
    "extensions.update.notifyUser": false,
    "javascript.enabled": true,
    "network.manage-offline-status": false,
    "network.http.phishy-userpass-length": 255,
    "offline-apps.allow_by_default": true,
    "prompts.tab_modal.enabled": false,
    "security.fileuri.origin_policy": 3,
    "security.fileuri.strict_origin_policy": false,
    "signon.rememberSignons": false,
    "toolkit.networkmanager.disable": true,
    "toolkit.telemetry.prompted": 2,
    "toolkit.telemetry.enabled": false,
    "toolkit.telemetry.rejected": true,
    "xpinstall.signatures.required": false,
    "xpinstall.whitelist.required": false
  },
  "mutable": {
    "browser.dom.window.dump.enabled": true,
    "browser.laterrun.enabled": false,
    "browser.newtab.url": "about:blank",
    "browser.newtabpage.enabled": false,
    "browser.startup.page": 0,
    "browser.startup.homepage": "about:blank",
    "browser.startup.homepage_override.mstone": "ignore",
    "browser.usedOnWindows10.introURL": "about:blank",
    "dom.max_chrome_script_run_time": 30,
    "dom.max_script_run_time": 30,
    "dom.report_all_js_exceptions": true,
    "javascript.options.showInConsole": true,
    "network.captive-portal-service.enabled": false,
    "security.csp.enable": false,
    "startup.homepage_welcome_url": "about:blank",
    "startup.homepage_welcome_url.additional": "about:blank",
    "webdriver_accept_untrusted_certs": true,
    "webdriver_assume_untrusted_issuer": true
  }
}
fabian-gubler commented 1 year ago

I tried copying, but as NixOS has an immutable file system it didn't work. Sorry for my inactivity, I couldn't resolve this issue myself. I will close due to inactivity.