no module named data.testing - python

I have a questions about potential installation issues. I am running a code for research from https://github.com/XuecaiHu/Meta-SR-Pytorch.git. I used conda to create an environment where I can use the required python 3.5.4 version. After installing necessary packeges I run in to this error. I would greatly appreciate it help with this.
(MetaSR) name#name-MacBook-Air Meta-SR-Pytorch % python main.py --model metardn --save metardn --ext sep --pre_train ./experiment/metardn/model/model_1000.pt --test_only --data_test testing --scale 1.5 --n_GPUs 1
[1.5]
Traceback (most recent call last):
File "main.py", line 14, in <module>
loader = data.Data(args) ##data loader
File "/Users/name/Meta-SR-Pytorch/data/__init__.py", line 24, in __init__
module_test = import_module('data.' + args.data_test.lower())
File "/Users/name/opt/anaconda3/envs/MetaSR/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 985, in _gcd_import
File "<frozen importlib._bootstrap>", line 968, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
ImportError: No module named 'data.testing'

Related

Why does pysmell installation in vscode produces this error?

I have been trying to install pysmell in vscode but there seem to generate this error whenever i do that. Can someone help me understand and resolve this. Thank you!
Traceback (most recent call last):
File "C:\Users\abhil\AppData\Local\Programs\Python\Python39\Scripts\pysmell-script.py", line 33, in <module>
sys.exit(load_entry_point('pysmell', 'console_scripts', 'pysmell'))
File "C:\Users\abhil\AppData\Local\Programs\Python\Python39\Scripts\pysmell-script.py", line 25, in importlib_load_entry_point
return next(matches).load()
File "C:\Users\abhil\AppData\Local\Programs\Python\Python39\lib\importlib\metadata.py", line 77, in load
module = import_module(match.group('module'))
File "C:\Users\abhil\AppData\Local\Programs\Python\Python39\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 790, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "C:\Users\abhil\AppData\Local\Programs\Python\Python39\lib\site-packages\pysmell\tags.py", line 17, in <module>
from pysmell.codefinder import ModuleDict, processFile
File "C:\Users\abhil\AppData\Local\Programs\Python\Python39\lib\site-packages\pysmell\codefinder.py", line 13, in <module>
import __builtin__
ModuleNotFoundError: No module named '__builtin__'
I was following this link (https://code.google.com/archive/p/pysmell/) for the installation process. I have already done python setup.py install and python setup.py develop. the problem is in the import pysmell part.
Pysmell uses the module __builtin__, which was renamed to builtins in Python 3. You might have to switch to Python 2, or find a different alternative to Pysmell.

Error: class uri 'eventlet' invalid or not found

I've been running a dockerized flask application that uses Celery to run tasks.
To run the app I'm using gunicorn with eventlet and It's been working fine using alpine linux distribution.
However I had to move to ubuntu due to some issues with sklearn and other libraries, and now I'm having problems to run my app.
First of all I'm getting this error:
Error: class uri 'eventlet' invalid or not found:
[Traceback (most recent call last):
File "/myapp/env/lib/python3.6/site-packages/gunicorn/workers/geventlet.py", line 11, in <module>
import eventlet
ModuleNotFoundError: No module named 'eventlet'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/myapp/env/lib/python3.6/site-packages/gunicorn/util.py", line 135, in load_class
mod = import_module('.'.join(components))
File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/myapp/env/lib/python3.6/site-packages/gunicorn/workers/geventlet.py", line 13, in <module>
raise RuntimeError("You need eventlet installed to use this worker.")
RuntimeError: You need eventlet installed to use this worker.
Then I tried by adding pip install eventlet to my app's Dockerfile, and now I have this another error:
Error: class uri 'eventlet' invalid or not found:
[Traceback (most recent call last):
File "/myapp/env/lib/python3.6/site-packages/gunicorn/util.py", line 135, in load_class
mod = import_module('.'.join(components))
File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/myapp/env/lib/python3.6/site-packages/gunicorn/workers/geventlet.py", line 11, in <module>
import eventlet
File "/myapp/env/lib/python3.6/site-packages/eventlet/__init__.py", line 10, in <module>
from eventlet import convenience
File "/myapp/env/lib/python3.6/site-packages/eventlet/convenience.py", line 7, in <module>
from eventlet.green import socket
File "/myapp/env/lib/python3.6/site-packages/eventlet/green/socket.py", line 21, in <module>
from eventlet.support import greendns
File "/myapp/env/lib/python3.6/site-packages/eventlet/support/greendns.py", line 69, in <module>
setattr(dns.rdtypes.IN, pkg, import_patched('dns.rdtypes.IN.' + pkg))
File "/myapp/env/lib/python3.6/site-packages/eventlet/support/greendns.py", line 59, in import_patched
return patcher.import_patched(module_name, **modules)
File "/myapp/env/lib/python3.6/site-packages/eventlet/patcher.py", line 126, in import_patched
*additional_modules + tuple(kw_additional_modules.items()))
File "/myapp/env/lib/python3.6/site-packages/eventlet/patcher.py", line 100, in inject
module = __import__(module_name, {}, {}, module_name.split('.')[:-1])
File "/myapp/env/lib/python3.6/site-packages/dns/rdtypes/IN/WKS.py", line 25, in <module>
_proto_tcp = socket.getprotobyname('tcp')
OSError: protocol not found
This is how I start my app (start.sh):
gunicorn -w 1 --worker-class eventlet --certfile=myapp/myapp.crt --keyfile=myapp/myapp.key --bind 0.0.0.0:5000 --log-config myapp/gunicorn.conf myapp.run:app
It's been working fine until I moved to an ubuntu based container.
What am I missing here?
I appreciate any help.
Thanks!
I had the same issue, and I found that it is caused by some updates made by eventlet they removed eventlet.wsgi.ALREADY_HANDLED but gunicorn is still using it. So , you better downgrade the eventlet version.
pip install gunicorn==20.1.0 eventlet==0.30.2
Here is a reference https://github.com/eventlet/eventlet/issues/702
I'll post the solution I've found in case it's useful to anyone.
Just I was missing the /etc/protocols, and this is how I've fixed it:
I had to add this step in my Dockerfile:
RUN apt-get -o Dpkg::Options::='--force-confmiss' install --reinstall -y netbase
I tried for a lot and finally working, please check these:
gunicorn==20.1.0 eventlet==0.30.2 (error source: https://github.com/benoitc/gunicorn/pull/2581)
python version under 3.10 (error source: https://github.com/eventlet/eventlet/issues/687)
If u are using heroku, edit the requeriments.txt adding gunicorn and eventlet version and also edit runtime.txt with "python-3.9.13" (In case you are using heroku stack 22). If you are running another heroku stack, please check it's python compatible versions. (source = https://devcenter.heroku.com/articles/python-support#supported-runtimes)

How to fix ImportError "_psutil_linux" on Heroku

I need psutil in my code but I get the error "importError _psutil_linux" on Heroku
it's for a status application on the use of the system and what's left of free.
I've already tried:
- to force the installation with pip (not work)
- to change the version with the file requirements.txt (not work)
requirements.txt :
Unidecode==1.0.22
youtube_dl==2018.7.21
chardet==3.0.4
urlextract==0.8.3
feedparser==5.2.1
requests==2.18.4
setuptools==40.2.0
aiohttp==1.0.5
urllib3==1.22
discord.py==0.16.12
psutil==5.4.7
pip==9.0.3
pyparsing==2.2.0
Pillow==5.3.0
beautifulsoup4==4.6.3
httplib2==0.11.3
imgurpython==1.1.7
keyboard==0.13.2
google_api_python_client==1.7.4
pyfiglet==0.7.5
pylast==2.4.0
r6sapi==0.8.0
raven==6.9.0
raven_aiohttp==0.7.0
tabulate==0.8.2
typing==3.6.6
my use of psutil :
import psutil
CPU = psutil.cpu_percent()
RAM =psutil.virtual_memory().percent
(in a discord bot command.)
Traceback (most recent call last):
File "/app/cogs/owner.py", line 65, in load
self._load_cog(module)
File "/app/cogs/owner.py", line 946, in _load_cog
mod_obj = importlib.import_module(cogname)
File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/app/cogs/cyvgeneral.py", line 7, in <module>
import psutil
File "lib/psutil/__init__.py", line 100, in <module>
from . import _pslinux as _psplatform
File "lib/psutil/_pslinux.py", line 26, in <module>
from . import _psutil_linux as cext
ImportError: cannot import name '_psutil_linux'
I expect Psutil to load correctly.
thank you in advance.

shell_plus installed with Django giving error - ImportError: cannot import name 'Type

I am getting the following error when trying to launch shell_plus after installing django_extensions. Here are the steps i followed
1-Installed django_extensions using
pip install django_extensions
2-Added django_extensions to installed apps
Then I get the following error
$ ./manage.py shell_plus
Traceback (most recent call last):
File "./manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/Users/admin/Development/project/virtual/lib/python3.5/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
utility.execute()
File "/Users/admin/Development/project/virtual/lib/python3.5/site-packages/django/core/management/__init__.py", line 365, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/admin/Development/project/virtual/lib/python3.5/site-packages/django/core/management/__init__.py", line 216, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/Users/admin/Development/project/virtual/lib/python3.5/site-packages/django/core/management/__init__.py", line 36, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 662, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "/Users/admin/Development/project/virtual/lib/python3.5/site-packages/django_extensions/management/commands/shell_plus.py", line 14, in <module>
from django_extensions.management.shells import import_objects
File "/Users/admin/Development/project/virtual/lib/python3.5/site-packages/django_extensions/management/shells.py", line 5, in <module>
from typing import ( # NOQA
ImportError: cannot import name 'Type'
Any suggestions on what might be going wrong ?
Python 3.5 comes with its own version of typing module. What is most likely happening is that you have the other typing module specified in your requirements (the one that doesn't include Type class) and its getting picked up by django_extensions instead of the native Python one. Check your installed modules, or try running:
pip uninstall typing

django-axes installed, but axes.middleware module not available

I recently refactored a lot of code and wanted a clean environment, so I deleted and recreated the database schema, created a new venv, and installed dependencies from pip3 one-by-one so I didn't have any superfluous packages left over from the old environment. I quickly installed half a dozen packages, then migrate passed. However, runserver complaines that axes.middleware isn't found (it is installed).
I have django-axes 2.2.0 installed in my virtual environment (Edit: python 3.5, django 1.10).
I verfied the installation was present with pip3 freeze, after
uninstalling and reinstalling just to be sure. django-axes==2.2.0
I have axes listed in INSTALLED_APPS
I have axes.middleware.FailedLoginMiddleware listed in MIDDLEWARE_CLASSES. Note that if I comment out this line, django doesn't attempt to import axes.middleware and consequently runserver succeeds.
I can do import axes; axes.get_version() and also from axes.decorators import watch_login on the shell, so clearly axes is available to the environment.
What is going wrong here?
Traceback from ./manage.py runserver:
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7f2d43a381e0>
Traceback (most recent call last):
File "/webapps/my_app/lib/python3.5/site-packages/django/core/servers/basehttp.py", line 49, in get_internal_wsgi_application
return import_string(app_path)
File "/webapps/my_app/lib/python3.5/site-packages/django/utils/module_loading.py", line 20, in import_string
module = import_module(module_path)
File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 665, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "/webapps/my_app/wsgi.py", line 14, in <module>
application = get_wsgi_application()
File "/webapps/my_app/lib/python3.5/site-packages/django/core/wsgi.py", line 14, in get_wsgi_application
return WSGIHandler()
File "/webapps/my_app/lib/python3.5/site-packages/django/core/handlers/wsgi.py", line 153, in __init__
self.load_middleware()
File "/webapps/my_app/lib/python3.5/site-packages/django/core/handlers/base.py", line 56, in load_middleware
mw_class = import_string(middleware_path)
File "/webapps/my_app/lib/python3.5/site-packages/django/utils/module_loading.py", line 20, in import_string
module = import_module(module_path)
File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 956, in _find_and_load_unlocked
ImportError: No module named 'axes.middleware'
As of 2.0.0, django-axes has default_app_config so you can just use axes in INSTALLED_APPS without installing middleware. Hence, delete the relevant MIDDLEWARE_CLASSES line in settings.py

Categories