So I was working with python, coding and installing packages, everything was going ok, but then everything with pip stoped working, and every times the cmd prompt me :
Traceback (most recent call last):
File "c:\python39\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\python39\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Python39\Scripts\pip.exe\__main__.py", line 7, in <module>
File "c:\python39\lib\site-packages\pip\_internal\cli\main.py", line 69, in main
command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
File "c:\python39\lib\site-packages\pip\_internal\commands\__init__.py", line 91, in create_command
module = importlib.import_module(module_path)
File "c:\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 855, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "c:\python39\lib\site-packages\pip\_internal\commands\list.py", line 9, in <module>
from pip._internal.cli.req_command import IndexGroupCommand
File "c:\python39\lib\site-packages\pip\_internal\cli\req_command.py", line 20, in <module>
from pip._internal.index.collector import LinkCollector
File "c:\python39\lib\site-packages\pip\_internal\index\collector.py", line 5, in <module>
import cgi
File "c:\python39\lib\cgi.py", line 41, in <module>
import html
ModuleNotFoundError: No module named 'html'
I never run into those kind of errors.
BTW pip -V is working, and when I try to run a programme using python with the already installed package and it still works fine.
I tried to reinstall python partially after restarting my pc, and nothing with pip has changed
I fixed it, here is what I have done, and more context that may help you understand where the problem was coming from :
So I was doing an gui app using pyqt5 and I was having trouble with PySide2, the first error of this kind was when I tried to install it with pip (pip install PySide2). I don't know where the error came from, but if you encounter this after in a similar situation, there way be a problem with that.
what I have done to fix it was not re-installing python or pip but using the repair "tool" when installing the version of python already installed.
Related
I've got an error when I try to update the python runtime of a function Azure, from 3.6 to 3.7 or 3.8, because version 3.6 is no longer used in Azure.
This is the full error:
Result: Failure Exception: AttributeError: module 'os' has no attribute 'add_dll_directory' Stack: File "/azure-functions-host/workers/python/3.8/LINUX/X64/azure_functions_worker/dispatcher.py", line 355, in _handle__function_load_request func = loader.load_function( File "/azure-functions-host/workers/python/3.8/LINUX/X64/azure_functions_worker/utils/wrappers.py", line 40, in call return func(*args, **kwargs) File "/azure-functions-host/workers/python/3.8/LINUX/X64/azure_functions_worker/loader.py", line 127, in load_function mod = importlib.import_module(fullmodname) File "/usr/local/lib/python3.8/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1014, in _gcd_import File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 671, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 843, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/home/site/wwwroot/CopyTransactionHttpTrigger/__init__.py", line 8, in <module> from confluent_kafka import avro File "/home/site/wwwroot/.python_packages/lib/site-packages/confluent_kafka/__init__.py", line 18, in <module> _delvewheel_init_patch_16682001180() File "/home/site/wwwroot/.python_packages/lib/site-packages/confluent_kafka/__init__.py", line 9, in _delvewheel_init_patch_16682001180 os.add_dll_directory(libs_dir)
Python 3.7 and 3.8
modules in requirements.txt file:
azure-functions==1.12.0 confluent-kafka==1.7.0 confluent-kafka[avro]==1.7.0 requests azure.storage.blob
I tried to update the function Azure with python 3.7 and 3.8 installing all dependencies above (modules) with such runtimes.
I think this module is necessary => module 'os' has no attribute 'add_dll_directory', and I don't know how to solve it.
What I see on the documentation of os module, it's used for windows. Do I need this module (os) in Azure?, can I avoid it by code?, if so, how?
I just install the function in linux on my local machine and deploy it from there adn it works. The issue was that I was deplying form a windows environtment.
I'm setting up my Django Rest API on Linux instance-template-1 5.10.0-14-cloud-amd64 #1 SMP Debian 5.10.113-1 (2022-04-29) x86_64
Python 3.9 is installed and Django 4x
I've installed One signal required by my API using
sudo pip3 install onesignal
sudo pip3 install onesignal_sdk
The module not found error throws up when I run
sudo python3.9 manage.py migrate
The detailed error trace is as follows :
File "/home/lineofsight/myprojects/my API/manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.9/dist-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.9/dist-packages/django/core/management/__init__.py", line 420, in execute
django.setup()
File "/usr/local/lib/python3.9/dist-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/local/lib/python3.9/dist-packages/django/apps/registry.py", line 116, in populate
app_config.import_models()
File "/usr/local/lib/python3.9/dist-packages/django/apps/config.py", line 304, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib/python3.9/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 "/home/lineofsight/myprojects/My API/myapp_auth/models.py", line 25, in <module>
from myapp_notifications.helpers import get_notification_language_code_for_target_user
File "/home/lineofsight/myprojects/My API/myapp_notifications/helpers.py", line 4, in <module>
import onesignal as onesignal_sdk
File "/usr/local/lib/python3.9/dist-packages/onesignal/__init__.py", line 3, in <module>
from onesignal_client import OneSignal
ModuleNotFoundError: No module named 'onesignal_client'
I think you didn't install the correct python location.
Please try to install using the following commands.
python3.9 -m pip install onesignal
python3.9 -m pip install onesignal_sdk
I already setup the configurations in Odoo 10 but still facing with this error. I am using docker and eclipse. Any idea for this?
Traceback (most recent call last):
File "/home/user/Desktop/odoo-workspace/odoo10/odoo-bin", line 5, in <module>
__import__('pkg_resources').declare_namespace('odoo.addons')
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2269, in declare_namespace
declare_namespace(parent)
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2285, in declare_namespace
_handle_ns(packageName, path_item)
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2218, in _handle_ns
loader.load_module(packageName)
File "<frozen importlib._bootstrap_external>", line 462, in _check_name_wrapper
File "<frozen importlib._bootstrap_external>", line 962, in load_module
File "<frozen importlib._bootstrap_external>", line 787, in load_module
File "<frozen importlib._bootstrap>", line 262, in _load_module_shim
File "<frozen importlib._bootstrap>", line 604, in _exec
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/user/Desktop/odoo-workspace/odoo10/odoo/__init__.py", line 57, in <module>
import addons
ModuleNotFoundError: No module named 'addons'
Already solved. I changed the python interpreter to Python2.7 and installed pip.
To install pip for Python 2.7 install it from \https://bootstrap.pypa.io/pip/2.7/ :
curl -O https://bootstrap.pypa.io/pip/2.7/get-pip.py
python get-pip.py
python -m pip install --upgrade "pip < 21.0"
after that I entered this command so that it will get all the requirements well:
pip install -r requirements.txt
Hi I am pretty new to django and I ended up with a very big error when I tried running the command python3 manage.py syncdb. I am trying to create a form builder application and encountered the error when I was trying to sync the database with the project. I am using the django-forms-builder from pypi.org.
For the error:
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
utility.execute()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/core/management/__init__.py", line 338, in execute
django.setup()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/apps/config.py", line 94, in create
module = import_module(entry)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'foo'
Any kind of help will be appreciated.
You must have forgotten to install a dependency that is listed in your INSTALLED_APPS. Try pip install foo. Or you can remove foo from the installed apps.
I am trying to get a screenshot utility to work after porting it from:
PyQt4 -> PyQt5
Python 2.7 -> Python 3.7
Ubuntu -> Windows 7
original code
new ported code
I changed all the Qt4 references over to Qt5 and got it mostly working except for the Select Area function that lets you select an area on the screen by drawing a rectangle. This part fails with the error:
resArea: Traceback (most recent call last):
File "screenshot.py", line 318, in <module>
d = display.Display()
File "C:\Users\frak\AppData\Local\Programs\Python\Python37\lib\site-packages\python_xlib-0.24-py3.7.egg\Xlib\display.py", line 89, in __init__
File "C:\Users\frak\AppData\Local\Programs\Python\Python37\lib\site-packages\python_xlib-0.24-py3.7.egg\Xlib\display.py", line 71, in __init__
File "C:\Users\frak\AppData\Local\Programs\Python\Python37\lib\site-packages\python_xlib-0.24-py3.7.egg\Xlib\protocol\display.py", line 85, in __init__
File "C:\Users\frak\AppData\Local\Programs\Python\Python37\lib\site-packages\python_xlib-0.24-py3.7.egg\Xlib\support\connect.py", line 72, in get_display
File "C:\Users\frak\AppData\Local\Programs\Python\Python37\lib\site-packages\python_xlib-0.24-py3.7.egg\Xlib\support\connect.py", line 55, in _relative_import
File "C:\Users\frak\AppData\Local\Programs\Python\Python37\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 668, in _load_unlocked
File "<frozen importlib._bootstrap>", line 638, in _load_backward_compatible
File "C:\Users\frak\AppData\Local\Programs\Python\Python37\lib\site-packages\python_xlib-0.24-py3.7.egg\Xlib\support\unix_connect.py", line 31, in <module>
ModuleNotFoundError: No module named 'fcntl'
I know that fcntl isn't supported on Windows but I think there could be a workaround since I think what the code is trying to do is get some screen dimensions before proceeding.
All the research I've done so far points me to other things like pyscreenshot or alternative implementations that only do a full-screen grab but don't have a rectangular selector to select a screen region.
I like this implementation because it shows you a quick preview and options to select an area, adjust delay, hide window and save to file.
Any help would be greatly appreciated