Closed halhwadi closed 1 year ago
Hi!
virtualenv
(or venv for Python3) is a command that installs python to a local directory. When you run python from that directory, all the changes are confined to that directory. This means that you don't accidentally change anything globally.
I don't know exactly how you're running python on windows (from PowerShell, or WSL, or Linux in a HyperV VM), but it sounds like the vapid
executable script isn't in your path. I'm guessing you're probably running it outside of the path you installed it. If you like, virtualenv
does provide an activate
command (I think it's activate.bat
on windows) which will add the local python binary to your path so long as you have that session open. (It doesn't add it globally forever, just to that window.)
Thank you Colin for your detailed response 👍 I run python on widows using pycharm IDE terminal or sometomes directly on Paython, CMD or Powershell , I have installed vapid on virtual Env. and on my system python and check its availability under site-packeges for both but with no luck! Anyway I can get public and private keys directly from webpush codelab site or from firabase so I don't think I need vapid anymore, is it right? Regards Sent from Yahoo Mail on Android
On Wed, 10 Nov 2021 at 11:24 pm, JR @.***> wrote:
Hi!
virtualenv (or venv for Python3) is a command that installs python to a local directory. When you run python from that directory, all the changes are confined to that directory. This means that you don't accidentally change anything globally.
I don't know exactly how you're running python on windows (from PowerShell, or WSL, or Linux in a HyperV VM), but it sounds like the vapid executable script isn't in your path. I'm guessing you're probably running it outside of the path you installed it. If you like, virtualenv does provide an activate command (I think it's activate.bat on windows) which will add the local python binary to your path so long as you have that session open. (It doesn't add it globally forever, just to that window.)
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.
Using keys that are generated on a site is possible (so long as they're the right encryption format), but it's not very secure. If you're just using them for something personal or teaching yourself how to code, there's no problem. I would not suggest that you use those keys for anything important or as part of anything you give to someone else. It's also a VERY good idea to use a different key for VAPID and a different key for encrypting the message, for the same security reasons.
Also, when you run virtualenv
or python -m venv
you have to give a directory you want python to install into.
(for example: python3 -m venv venv_dir
will create a new directory called venv_dir
and install python under venv_dir
. You would then call venv_dir/bin/python3
to use that new, virtual environment python.
It can be confusing because many examples will use something like python3 -m venv venv
which creates a new directory called venv
that contains python. It sounds a bit like you're still learning python, which is good! You may want to read up a bit more about how some of the install and tooling work, though, because some of it can be hard to understand.
Try looking up things like python3 "setup.py"
or python3 venv tutorial
. From personal experience, I find windows to be a very good host system for running linux virtual machines to do my development. I've hit far too many bumps trying to get tools to understand how windows wants to do things.
Appreciate your time and effort in writing such detailed response enrich with good guidance.. I got confused many times when it comes to figure out which python intrepertor is involved in package installation!! I have one virtual python environment in addition to the root one and found that root one is more stable with respect to packages installation and thats why I point pycharm to use it meanwhile I use the virtual environment to execute my django project, I know how bad to use different environments in any project and how is difficult to keep them updated, I will dedicate some time to sort this issue in order to use only the virtual environment before production deployment and will spend sometime on reading as per your advice.. Regarding vapid keys; I installed many ready django packages like django_push_notification and lastly decided to go with FCM(Firebase), however the blocker I'm facing currently is getting and displaying the message, I use firebase javascript API and managed to get token but not able to run service worker ( firebase-messaging-sw.js) due to import module issues, I know this issue is completely not related to vapid but I would like to share issue link with you hope to listen from you ( if you wish and can assist): Unable to import firebase module inside firebase-messaging-sw.js | |
---|---|
|
Unable to import firebase module inside firebase-messaging-sw.js
Im working on firebase messaging service to send push notification via django web application to web app on Andriod,IOS and website as well, I managed to get token and run sw ,however i can't runni... | |
|
|
Sent from Yahoo Mail on Android
On Mon, 15 Nov 2021 at 9:36 pm, JR @.***> wrote:
Using keys that are generated on a site is possible (so long as they're the right encryption format), but it's not very secure. If you're just using them for something personal or teaching yourself how to code, there's no problem. I would not suggest that you use those keys for anything important or as part of anything you give to someone else. It's also a VERY good idea to use a different key for VAPID and a different key for encrypting the message, for the same security reasons.
Also, when you run virtualenv or python -m venv you have to give a directory you want python to install into. (for example: python3 -m venv venv_dir will create a new directory called venv_dir and install python under venv_dir. You would then call venv_dir/bin/python3 to use that new, virtual environment python.
It can be confusing because many examples will use something like python3 -m venv venv which creates a new directory called venv that contains python. It sounds a bit like you're still learning python, which is good! You may want to read up a bit more about how some of the install and tooling work, though, because some of it can be hard to understand.
Try looking up things like python3 "setup.py" or python3 venv tutorial. From personal experience, I find windows to be a very good host system for running linux virtual machines to do my development. I've hit far too many bumps trying to get tools to understand how windows wants to do things.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.
Like every language, python has it's own quirks. One of them is that because so many system things depend on Python, it's A Good Idea to do development in a protected "virtual environment". There, you can go crazy, make mistakes, and otherwise break things without breaking the system needed by the OS. Life becomes a good deal better when you take time to sort things out.
Getting the message can be a bit different for each platform. For Firefox, there are a few examples that are pretty straight-forward. You can try looking at https://serviceworke.rs/web-push.html for how to do things. It sounds like you're fairly close. For a lot of reasons, you need to create a separate "Service Worker" file that handles getting the actual message. That will run on a separate, limited thread. It then can communicate with your application thread using something like postMessage
I'm not sure I can really help much with that part, but there are lots of good tutorials out there.
closing as inactive.
I'm following this link to create web push notification for my App, right now I'm stuck in step2 (creating public and private key) because I can't run this command(even tough I have implemented successfully the vapid
vapid --sign claim.json
I got this error when running this command!! 'vapid' is not recognized as an internal or external command,
Env(windows 10)