Python manage.py runserver error doing Python Crash Course - python

Trying the python crash course web app project.
Python manage.py runserver is throwing off a bunch of errors
Exception in thread django-main-thread: Traceback (most recent call
last): File
"/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py",
line 917, in _bootstrap_inner self.run() File
"/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py",
line 865, in run self._target(*self._args, **self._kwargs) File
"/Users/me/Pictures/Python/learning_log/ll_env/lib/python3.7/site-packages/django/utils/autoreload.py",
line 54, in wrapper fn(*args, **kwargs
I figured it out actually, but not sure why or how it works, but decided to leave it here in case someone comes across the same problem in the future.
In the urls.py file, the textbook tells you to add
"url(r'', include('learning_logs.urls', namespace='learning_logs')),"
what fixes it is adding this instead of the above,
"path('', include('learning_logs.urls'), name='learning_logs'),"
'''
python manage.py runserver
'''

What solved my problem was: using this line instead of the one from the textbook
"path('', include('learning_logs.urls'), name='learning_logs'),"

Related

issue with hubble-pi camera capture

I have recently tried to install and get working a program developed to use with a telescope. It is called hubble-pi and can be found here. https://github.com/RemovedMoney326/Hubble-Pi
The program runs but when i click the capture button I get this issue. I have reached out to the dev but he has not replied and that was over a month ago. If anyone could assist in figuring out a solution that be awesome.
Im a beginner when it comes to python so be easy. This is also happening on boot up as this is the first thing im doing when turning on my RPI. I am running this on a RPI 4 2gb.
Python 3.7.3 (/usr/bin/python3)
>>> %Run AstroCam.py
Start
Capture
mmal: mmal_vc_component_enable: failed to enable component: ENOSPC
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner
self.run()
File "/usr/lib/python3.7/threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "/home/pi/AstroCameraApp/PythonScripts/AstroCam.py", line 60, in camHandler
camera.resolution = DynamicCaptureResolution #set photo size
File "/usr/lib/python3/dist-packages/picamera/camera.py", line 2282, in _set_resolution
self._enable_camera()
File "/usr/lib/python3/dist-packages/picamera/camera.py", line 1976, in _enable_camera
self._camera.enable()
File "/usr/lib/python3/dist-packages/picamera/mmalobj.py", line 724, in enable
prefix="Failed to enable component")
File "/usr/lib/python3/dist-packages/picamera/exc.py", line 184, in mmal_check
raise PiCameraMMALError(status, prefix)
picamera.exc.PiCameraMMALError: Failed to enable component: Out of resources
I just hit this same error with another Picamera IMX477 app, and found a fix.
Set gpu-mem=192 in /boot/config.txt, reboot, and 4032x3040 starts working.
This is for Pi-4, 2GB running Buster. Bullseye is a different animal.

Threads with PySimpleGui gives RunTimeError

I have explored using threads with PySimpleGui but quite often the thread terminates
RuntimeError: main thread is not in main loop
I have tried running the "official" demos, forexample:
https://github.com/PySimpleGUI/PySimpleGUI/blob/master/DemoPrograms/Demo_Multithreaded_Long_Task_Simple.py
This gives me the runtime error when I run it locally. However when I run the same demo on trinket :
https://pysimplegui.trinket.io/demo-programs#/multi-threaded/multi-threaded-long-task-simple
It seems to run fine. I am using
windows 10
Anaconda
python 3.8
spyder 4.2 (IDLE)
I have also tried to run outside spyder (IDLE) with the same effect.
Full error message:
*Exception in thread Thread-8:
Traceback (most recent call last):
File "C:\Users\xxx\.conda\envs\python38\lib\threading.py", line 932, in _bootstrap_inner
self.run()
File "C:\Users\xxx\.conda\envs\python38\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "C:\xxxx\Demo_Multithreaded_Long_Task_Simple.py", line 31, in long_operation_thread
window.write_event_value('-PROGRESS-', progress)
File "C:\Users\xxx\.conda\envs\python38\lib\site-packages\PySimpleGUI\PySimpleGUI.py", line 8940, in write_event_value
self.thread_strvar.set('new item')
File "C:\Users\xxx\.conda\envs\python38\lib\tkinter\__init__.py", line 365, in set
return self._tk.globalsetvar(self._name, value)
RuntimeError: main thread is not in main loop*`

Python - Solving command line error for Tweepy

I am trying to use Tweepy to stream Tweets from a developer API. I want to convert this into an SQLite database file.
However, I am getting an unusual error that links to the Tweepy libraries on my computer. I am using Python 3.6.7 (if that might have something to do with it).
Please let me know if you require more information.
In Windows 10 command line:
Exception in thread Thread-1:
Traceback (most recent call last):
File "C:\Users\CONFIDENTIAL\AppData\Local\Programs\Python\Python36\lib\threading.py", line 916, in _bootstrap_inner
self.run()
File "C:\Users\CONFIDENTIAL\AppData\Local\Programs\Python\Python36\lib\threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\CONFIDENTIAL\AppData\Local\Programs\Python\Python36\lib\site-packages\tweepy\streaming.py", line 293, in _run
self.listener.on_exception(exception)
AttributeError: 'int' object has no attribute 'on_exception'
When initializing tweepy.Stream, you're passing an integer for the listener parameter, rather than an instance of tweepy.StreamListener. See the Streaming with Tweepy section of Tweepy's documentation.

Multithreading frozen in Python Spyder but not command prompt Windows 10

I am running a script inside Spyder that utilizes the multithreading library and the IPython console freezes with the output below. However, running the script using Windows command prompt via 'python quickstart11.py' works fine and generates the proper output.
runfile('C:/Python35/User/backtrader-master/docs/quickstart/quickstart11.py', wdir='C:/Python35/User/backtrader-master/docs/quickstart')
Exception in thread Thread-8:
Traceback (most recent call last):
File "C:\Anaconda3\lib\threading.py", line 914, in _bootstrap_inner
self.run()
File "C:\Anaconda3\lib\threading.py", line 862, in run
self._target(*self._args, **self._kwargs)
File "C:\Anaconda3\lib\multiprocessing\pool.py", line 429, in _handle_results
task = get()
File "C:\Anaconda3\lib\multiprocessing\connection.py", line 251, in recv
return ForkingPickler.loads(buf.getbuffer())
AttributeError: Can't get attribute 'TestStrategy' on <module '__main__' (<_frozen_importlib_external.SourceFileLoader object at 0x000002727C461438>)>
I've tried adding freeze_support() according to Python doc, which should alleviate the problem, but it still freezes. What is going on?
Windows 10 64bit, Anaconda Python 35 64bit installer.
The problem is in Spyder. The kernel is running in interpreted mode and the addition of "freeze_support" doesn't happend before other things even if that's the intention, because the kernel is already running.
See here: https://github.com/mementum/backtrader/issues/118

pyramid project created with pycharm raises a ValueError: Variable assignment

I'm a newbie to python and I'm trying to work on a web project with the pyramid framework. I use pycharm 4.0.4.
After creating a new pyramid project with pycharm and running setup.py develop, the project generates a ValueError when I try to run it as shown below:
C:\Users\Ovurevu\vir1\Scripts\python.exe "C:\Program Files (x86)\JetBrains\PyCharm 4.0.4\helpers\pycharm\pycharm_load_entry_point.py" C:\Users\Ovurevu\Desktop\Python Scripts\Pyramid_one\development.ini
Traceback (most recent call last):
File "C:\Program Files (x86)\JetBrains\PyCharm 4.0.4\helpers\pycharm\pycharm_load_entry_point.py", line 8, in <module>
load_entry_point(dist, "console_scripts", name)()
File "C:\Users\Ovurevu\vir1\lib\site-packages\pyramid\scripts\pserve.py", line 58, in main
return command.run()
File "C:\Users\Ovurevu\vir1\lib\site-packages\pyramid\scripts\pserve.py", line 257, in run
vars = self.get_options()
File "C:\Users\Ovurevu\vir1\lib\site-packages\pyramid\scripts\pserve.py", line 197, in get_options
return parse_vars(restvars)
File "C:\Users\Ovurevu\vir1\lib\site-packages\pyramid\scripts\common.py", line 15, in parse_vars
% arg)
ValueError: Variable assignment 'Scripts\\Pyramid_one\\development.ini' invalid (no "=")
I have spent a lot of time trying to debug this issue.
What I'm I doing wrong?
I know this is an old question, but I just had this same error. I figured it out though. There shouldn't be anything wrong with the development.ini file.
Tested functionality via command line.
I believe it is because anything with a space is not parsed correctly. If you add " (quotes) around the path it will work.
Tested on

Categories