Python Daily
2.57K subscribers
1.48K photos
53 videos
2 files
38.9K links
Daily Python News
Question, Tips and Tricks, Best Practices on Python Programming Language
Find more reddit channels over at @r_channels
Download Telegram
Why Does the VS Code Jupyter Extension Keep Timing-out Trying to Find a Kernel That Exists?

I need to set up virtual environments for each language that I use. To do this, I'm running the Ubuntu 20.04 LTS Windows Subsystem for Linux (WSL) on Windows 10. Within WSL, I'm using Anaconda, installed in
/usr/local/Anaconda
, to create conda virtual environments for each language (i.e. one environment contains all my Python stuff, another contains my R stuff, etc.).

Since WSL doesn't come with a GUI, I'm using Visual Studio Code's (VSCode) Jupyter Notebook Extension to run Jupyter Notebooks to see plots/graphics. So far, I managed to easily create conda environments for Python (with ipython and ipykernel) and R (with IRkernel) and run their code in a notebook via the extension. Each time I set up an environment, the extension is easily able to find the kernel, connect to it and run the code.

However, I've not been able to set up an environment for Julia. I followed the documentation on the Julia website for installing the kernel, which is successfully found by the extension. But, when I try running a cell, the extension says it is trying to connect to the kernel, only for it to timeout and fail.

Here are the steps I have taken so far:

1. Create

/r/JupyterNotebooks
https://redd.it/uupwd4
How to remove double links

/r/flask
https://redd.it/uw28fy
Is Django-Celery appropriate here?

I come from a mainly MS background working with data (ETL) and I've recently migrated a lot of our companies processes to use a Django front end for simple configurations. Nice simple CRUD stuff for tables that feed into the ETL processes.

I also wrote a simple task processing package in Python. Tasks are all written as Python functions and include things like; run SQL procedure, download data from SQL into excel, FTP files to a third party etc. At present the tasks are requested by inserting a row into a table, the processor picks it up and saves away results; we have full visibility on when the task was requested, completed, and the 'results'/download of the task.

I also want it to handle more tasks, such as pushing new meta data to a production environment

Is this use case appropriate for Celery? Or do we need something like Apache Airflow? (I don't really understand the difference but was hoping for some input before I deep dive on one over the other!)

/r/django
https://redd.it/uw2sk3
Tuesday Daily Thread: Advanced questions

Have some burning questions on advanced Python topics? Use this thread to ask more advanced questions related to Python.

If your question is a beginner question we hold a beginner Daily Thread tomorrow (Wednesday) where you can ask any question! We may remove questions here and ask you to resubmit tomorrow.

This thread may be fairly low volume in replies, if you don't receive a response we recommend looking at r/LearnPython or joining the Python Discord server at https://discord.gg/python where you stand a better chance of receiving a response.

/r/Python
https://redd.it/uwdxeu
Need help understanding how JWT keep the api endpoint secure and how refresh tokens are recommended

I was reading jwt extended document

And in document it was mentioned that if your front end is not web and is mobile or api then it is recommended to use Refresh token

I know that jwt work by having a json payload and having a signature via your secret key

But how exactly does this make your api end point secure? And how will refresh token help?

Can you give me a simple example to help me understand

/r/flask
https://redd.it/uwmjk3
Updating login timestamp in database

Hey guys!

Im having an 'issue' with my web app. So I have a Login function which works as intendet and what I am trying to do is to update the login timestamps in my database. I got it working so that everytime a user logs in, it appends a new row with the user_id, a new timestamp and an id. My problem is that I just want to update the user specific row and not append a new one. Anybody knows how to solve this? thanks in advance!

/r/flask
https://redd.it/uwrgnf
Wednesday Daily Thread: Beginner questions

New to Python and have questions? Use this thread to ask anything about Python, there are no bad questions!

This thread may be fairly low volume in replies, if you don't receive a response we recommend looking at r/LearnPython or joining the Python Discord server at https://discord.gg/python where you stand a better chance of receiving a response.

/r/Python
https://redd.it/ux4liu
Django - PostHog analytics

Hi guys, I'm adding PostHog to my site I'm wondering what's better, installing PostHog to the Django server or installing it to the JS.

I think the same question would be if I were using Google Analitycs instead of PostHog.

Thanks!

/r/djangolearning
https://redd.it/uy7awd
Is there anyone who is graduated from Pybites "PDM program"? Is it worth it?

Is there anyone who is graduated from Pybites "PDM program"? Is it worth it?

Can you please share your experience with this program?

Anyone takes "PyBites Challenges"? What's your comment about their platform?

/r/django
https://redd.it/uycqvh
Sunday Daily Thread: What's everyone working on this week?

Tell /r/python what you're working on this week! You can be bragging, grousing, sharing your passion, or explaining your pain. Talk about your current project or your pet project; whatever you want to share.

/r/Python
https://redd.it/uzzd07
Can someone explain how to share models between apps?

So I'm new to django, and this is confusing as hell to me...

​

\- So I create my django project, and it automatically creates the database file.

\- I create an app, and in that app I make some models in my models.py

\- I make migrations, and django adds the models as tables to the database.

\- I create a second app, and I need that app to access the data in those tables.

​

How does the second app access the tables? Python won't let me import models.py without giving me a 'ModuleNotFound' error.

I know I can add a statement to settings.py to add the directory to sys.path, which will get it to work, but that feels hacky to me, and I'm concerned that there's just better ways of doing things with django that I'm not aware of.

If anyone can clear this up for me, I would appreciate it. Thank you!

​

EDIT: SOLVED!

​

thank you to u/timlwhite!

Turns out I had added my apps to INSTALLED_APPS incorrectly - I had just added 'my_app' instead of 'my_app.apps.MyAppConfig'

/r/django
https://redd.it/uzww8l
Stress Test / Limits of Web App

I have pushed to production on PythonAnywhere a web app that is essentially a glorified url shortener. Users can register, save a dozen of links and select one of them as their redirect page hosted at user_uuid/action . The app has been working well so far, but I plan to add about 500 users in the next 6 months. How can I roughly estimate the number of requests that the web app is able to bear? Is there a way to stress test?

/r/flask
https://redd.it/v0z21r
Django + Celery + AWS SQS setup on Elastic Beanstalk

Hi,

I am having a lot of trouble with the deployment to AWS Elastic Beanstalk of a Django app that uses Celery.

I want to deploy an app that runs a simple task every minute and prints something to the console. (I have the code attached below)

Locally, it works flawlessly

I start the beat: celery -A dcf\_env beat -l INFO
I start the worker: celery -A dcf_env worker -l INFO -P solo

I made an SQS queue named 'my-queue' which receives messages from my beat. And my worker successfully consumes the messages from the queue and prints something to the console.

I can't understand how to start the beat and the worker in AWS Elastic Beanstalk. Are they even supposed to run in Elastic Beanstalk, or do I need to use some other service like a separate EC2 instance?

What do my .config files need to look like in .ebextensions folder? Is my project structure even correct? (Project Structure photo attached below)

I have deployed the application without Celery before, but now I want to integrate the project with Celery running this simple_task.

Can anyone point me to the right tutorial on how to set this up, or any up to date documentation? Any help would be

/r/django
https://redd.it/v0uael
Tuesday Daily Thread: Advanced questions

Have some burning questions on advanced Python topics? Use this thread to ask more advanced questions related to Python.

If your question is a beginner question we hold a beginner Daily Thread tomorrow (Wednesday) where you can ask any question! We may remove questions here and ask you to resubmit tomorrow.

This thread may be fairly low volume in replies, if you don't receive a response we recommend looking at r/LearnPython or joining the Python Discord server at https://discord.gg/python where you stand a better chance of receiving a response.

/r/Python
https://redd.it/v1dbgz
Wednesday Daily Thread: Beginner questions

New to Python and have questions? Use this thread to ask anything about Python, there are no bad questions!

This thread may be fairly low volume in replies, if you don't receive a response we recommend looking at r/LearnPython or joining the Python Discord server at https://discord.gg/python where you stand a better chance of receiving a response.

/r/Python
https://redd.it/v23qzz