Django-redactor: name 'widgets' is not defined - python

When I try to import redactor.widgets in my Django app I get the error from the title. In the python command line importing redactor.widgetsdoesn't produce any errors. Does anyone have an idea as to why this is happening? Everything runs in a virtualenv, I tried installing django-redactor using pip and manually.
Thanks in advance.

Related

Why am I seeing "No module named '_tkinter" when I deploy django to heroku?

django works well on my local machine. But, when I deploy it to heroku, I see "ModuleNotFoundError" "No module named '_tkinter'". Though, I never imported "_tkinter" or "tkinter" in my code. Your help will be appreciated. Thank you.
ModuleNotFoundError at /
No module named '_tkinter'
Request Method: GET
Request URL: https://howididit.herokuapp.com/
Django Version: 4.0.6
Exception Type: ModuleNotFoundError
Exception Value:
No module named '_tkinter'
Exception Location: /app/.heroku/python/lib/python3.10/tkinter/init.py, line 37, in
Python Executable: /app/.heroku/python/bin/python
Python Version: 3.10.5
Python Path:
['/app/.heroku/python/bin',
'/app',
'/app/.heroku/python/lib/python310.zip',
'/app/.heroku/python/lib/python3.10',
'/app/.heroku/python/lib/python3.10/lib-dynload',
'/app/.heroku/python/lib/python3.10/site-packages']
If you don't use Tkinter, just remove it from /forms.py. otherwise it'll be imported.
If you want to use tkinter,then consider the below process
please try adding tkinter to your requirements.txt. If it fails, even after that, check if you have added Python buildpack. If both the cases pass, try shelling into your Heroku instances and run the following command:
sudo apt install python3-tk
This will install Tkinter library in your instance of Heroku. That will resolve your error.
I found out these from pyexpat import model from turtle import title from attr import fields where imported in my forms.py. After deleting them, The problem was solved. Again, thank you all guys for your time, I really appreciate it.
Okay so for anyone looking at this in the future and banging their head against the desk...this is what worked for me:
I started with a new Hello World app and started adding bits of my original code until i got to the error
found out that one of the modules I was using : icu, was using tkinter and i needed to install the Pyicu module instead
pip installed directly into heroku bash console instead of through my app
None of the answers i found online had worked for me, and I think its because this error isnt from having tkinter directly in your app, but from another module thats calling it.
When in doubt do what I did and start a new project from scratch and add chunks of code until you get the error to see which module is creating it
Dont forget to change DEBUG to False in your settings file

Problem with running python code on VS Code

[enter image description here][1]
Hello there,
I am facing the problem you can see in the image.
[1]: https://i.stack.imgur.com/qjV9Z.png
I have python installed in the D directory and added to path, everything looks like it should work.
I am creating a virtual environment for every project I am working on and I don't have any problems running commands like "pip install numpy" but when I try to run my code, even trying to import libraries it fails and the output in the picture is not very significant to me.
Has anyone faced a similar problem? can anyone help me?
Thanks in advance!
Judging from your screenshot, you have a file named numpy.py somewhere in your PYTHONPATH, causing Python to import that particular file instead of the NumPy library you intended.
See this link for more information on how Python import works: https://bic-berkeley.github.io/psych-214-fall-2016/sys_path.html

Unable to import pycolors (Pyling import error) Python error

I am currently trying to import some libraries/modules and everytime I try, it wont work and displays the pylint import error.
Here is what im trying to do:
import pycolors
I am using pylint, and I don't know how to fix this. I have watched several videos and done a ton of research, but none of them helped.
Pylint need to be in an environment where Pycolor is installed in order to not raise a warning . It's not clear whether the problem is when launching with python or analysing with pylint but in both case the solution is to install Pycolor: pip install Pycolor (If this is the one you want : https://pypi.org/project/Pycolor/)

Django error: unresolved import 'extra_views'

I'm trying to use extra_view Django package. I've installed it and in terminal it showed as successful and I added it to installed apps in setting.py. As I don't use virtual environment it's all installed globally, but when I try to import that package there is an unresolved import error. I use VS Code if it means something. It also happened with some other packages that I installed. Do you have any idea what is happening?
Can you show full traceback to this error?
And your code where you import it.
It should work fine if you do everything as it says here in the docs:
https://django-extra-views.readthedocs.io/en/latest/pages/getting-started.html
Everything is ok actually. I just restarted VS Code and then there weren't any errors anymore. Apparently VS Code was the only issue.

Python yahoo_fin Import Error

So I know this is nearly a duplicate of this ImportError question, but I'm not sure how to use those answers to fix this problem. I installed yahoo-fin package using my conda prompt:
pip install yahoo-fin
So clearly it is installed as Eclipse seems to recognize the package and I can even use cntl-space to autocomplete and F3 to explore the package. However, when I try to run
from yahoo_fin.stock_info import get_data
I get "ImportError: No module named stock_info".
From the SE question above I checked the init.py in the directory and it definitely has the CRLF problem, but even when I use notepad++ to replace "\r\n" with "\n" I still get the same error.
What am I missing?
Are you able to load the package without using Eclipse? I would try running Python from the command line, and then typing:
from yahoo_fin.stock_info import get_data
to see if that still gives you an error. If it still gives you an error, then we know it's not an Eclipse issue. However, if it does work, then it's probably an issue with Eclipse. In that case, I would maybe look at this other post: How To Make Eclipse Pydev Plugin Recognize Newly Installed Python Modules?.
Please let me know if that helps.

Categories

Resources