django-1.10 still contains deprecated and removed features - python

I am trying to run an existing django app. The app has been built in django-1.10. I set up a new virtualenv and installed the requirements and everything. However, I get errors like the following:
from django.utils import importlib
ImportError: cannot import name importlib
Now, the above is from the following source - .virtualenvs/crowd/lib/python2.7/site-packages/account/conf.py
When I manually fix the conf.py file, I still keep getting errors to fix either deprecated or removed features from older django versions.
Any idea as to how to fix this? I thought the purpose of working in virtualenvs was to avoid such errors.
Any suggestions would be much appreciated. Thanks in advance!
This is how the question is different: Even after I fix the importlib import statement, it keeps giving me errors like that of the usage of SubFieldBase and so on.

The problem was not with the Django-core but with django-user-accounts app that was included with pinax. Upgrading the django-user-accounts app fixed the issue.
Thanks to #Selcuk for the solution.

Related

Heroku release fails, error related to django.utils

So I updated my python code to Django 4.0 and with that, had to remove and update some deprecated code as "ungettext_lazy" and similar.
Locally, the code is compiling well but when I push it to heroku, I get this error:
from django.utils.translation import ungettext_lazy
ImportError: cannot import name 'ungettext_lazy' from 'django.utils.translation' (/app/.heroku/python/lib/python3.9/site-packages/django/utils/translation/__init__.py)
I've tried a few things but haven't been able to update this on heroku.
Basically solved it by removing the django-url-filter lib as it's not supporting django 4.0. Since I only used it for a small piece of code, it was better to remove it.
I solved this issue by swaping manually on requirements.txt Django==4.1 to Django==3.2.

Why am I unable to run the .login() attribute for robin_stocks?

I'm trying to import data from Robinhood through robin_stocks. I was able to import the package, but when I try to use the .login() attribute, it returns this error message in the Jupyter Notebook: error
module 'robin_stocks' has no attribute 'login'
I'm certain that robin_stocks does, indeed have the attribute that Python is telling me doesn't exist. Where did I go wrong here?
I'm relatively new to programming, but usually I can find an answer to my questions pretty quickly on StackOverflow or any other resource. I can't seem to figure this one out, though.
Any help would be greatly appreciated. Thank you!
I had the same error when upgrading from 1.7.x to 2.0.3
I was able to solve this by changing the import from:
import robin_stocks as rs
To:
import robin_stocks.robinhood as rs
Check the version of the package that you are using. I actually had the same issue when I migrated to a new laptop and installed packages again. I turned out that a newer robin-stocks python package got installed and resulted in an attribute error for my previously functioning code. When I reverted back to the older version of the package (1.5.5) my code worked like a charm.
Bro, we can't guess what you has typed in your code, please link it to us.
But if you have some issues with basic method of module, i think some thing gone wrong with import

Python flask.ext.mysql is deprecated?

When I run from flask.ext.mysql import MySQL I get the warning Importing flask.ext.mysql is deprecated, use flask_mysql instead.
So I installed flask_mysql using pip install flask_mysql,installed it successfully but then when I run from flask_mysql import MySQL I get the error No module named flask_mysql. In the first warning I also get Detected extension named flaskext.mysql, please rename it to flask_mysql. The old form is deprecated.
.format(x=modname), ExtDeprecationWarning. Could you please tell me how exactly should I rename it to flask_mysql?
Thanks in advance.
flask.ext. is a deprecated pattern which was used prevalently in older extensions and tutorials. The warning is telling you to replace it with the direct import, which it guesses to be flask_mysql. However, Flask-MySQL is using an even more outdated pattern, flaskext.. There is nothing you can do about that besides convincing the maintainer to release a new version that fixes it. from flaskext.mysql import MySQL should work and avoid the warning, although preferably the package would be updated to use flask_mysql instead.
flask.ext.X is the old form to import a Flask extension, it is deprecated since Flask v0.10. The new way is to use flask_X. That's why you got the first warning.
But apparently, Flask-MySQL does not update it's name form and use the flaskext as the package name (chedck it on GitHub). That's why you got the second warning.

ImportError: No module named locallibrary.settings

You could have seen the question so many times.
But unluckily I cant solve this error.
I am using python 2.7.12 , django 1.8
The tutorial source I learn is Mozilla django development where they teach with latest version of python3 and django 1.10
Somehow I tackled to use with older version.
everything was going good until I started to import models to admin.
soem class codes started showing that it has no object member, even though it exist
and hence I finally got the error as
"ImportError: No module named locallibrary.settings"
Here what I tried:
Updated to python 3(thought that could be the problem)
appended correct sys path() with project path.
Still same error showing up
Anybody help me out for solving the issue.
If you are trying to import the settings of your project, try importing
from django.conf import settings

ImportError when installing newspaper

I am pretty new to python and am trying to import newspaper for article extraction. Whenever I try to import the module I get ImportError: cannot import name images. Anyone come across this problem and found a solution?
I was able to fix this problem by creating an images directory in /usr/local/lib/python2.7/dist-packages/newspaper , moving images.py to this directory, and placing a blank __init__.py in this directory.
I know this is a dated entry, but to anyone else that faced the same issue as me, I initially fumbled with resolving this issue. When I first run import newspaper, I faced this error. lxml runtime error: Reason: Incompatible library version: etree.so requires version 12.0.0 or later, but libxml2.2.dylib provides version 10.0.0
When I tried to re-run my code (without correcting anything), I got the error found on this article. I have no idea why this was the case, and I wasn't able to resolve my issue using the above method (it didn't work for me, but it could still work for you). If anyone was fumbling like me on Jupyter on getting newspaper to work, do consider the link below. Hope this is helpful.
https://stackoverflow.com/a/31607751/6143792

Categories