Pip error in python when importing modules from pip - python

When i import modules from pip, like requests i get this error when running in VSCODE:
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: C:\Users\user\AppData\Local\Temp\tmp_6yww79s
The only code I used was:
import requests
I get the same error if i check pip version in terminal or other commands with pip:
pip --version
Full error:
PS C:\Script\Frost_met> & 'C:\Users\jrf\AppData\Local\Programs\Python\Python310\python.exe' 'c:\Users\jrf\.vscode\extensions\ms-python.python-2022.12.0\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher' '62406' '--' 'c:\Script\Frost_met\frost.py'
Traceback (most recent call last):
File "C:\Users\jrf\AppData\Local\Programs\Python\Python310\lib\importlib\_common.py", line 89, in _tempfile
os.write(fd, reader())
File "C:\Users\jrf\AppData\Local\Programs\Python\Python310\lib\importlib\abc.py", line 371, in read_bytes
with self.open('rb') as strm:
File "C:\Users\jrf\AppData\Local\Programs\Python\Python310\lib\importlib\_adapters.py", line 54, in open
raise ValueError()
ValueError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\Script\Frost_met\frost.py", line 4, in <module>
import requests
File "C:\Users\jrf\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\__init__.py", line 147, in <module>
from . import packages, utils
File "C:\Users\jrf\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\utils.py", line 24, in <module>
from . import certs
File "C:\Users\jrf\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\certs.py", line 14, in <module>
from certifi import where
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "C:\Users\jrf\AppData\Local\Programs\Python\Python310\lib\site-packages\wrapt\importer.py", line 177, in _exec_module
notify_module_loaded(module)
File "C:\Users\jrf\AppData\Local\Programs\Python\Python310\lib\site-packages\wrapt\decorators.py", line 470, in _synchronized
return wrapped(*args, **kwargs)
File "C:\Users\jrf\AppData\Local\Programs\Python\Python310\lib\site-packages\wrapt\importer.py", line 136, in notify_module_loaded
hook(module)
File "C:\Users\jrf\AppData\Local\Programs\Python\Python310\lib\site-packages\certifi_win32\wrapt_certifi.py", line 20, in apply_patches
certifi_win32.wincerts.CERTIFI_PEM = certifi.where()
File "C:\Users\jrf\AppData\Local\Programs\Python\Python310\lib\site-packages\certifi\core.py", line 37, in where
_CACERT_PATH = str(_CACERT_CTX.__enter__())
File "C:\Users\jrf\AppData\Local\Programs\Python\Python310\lib\contextlib.py", line 135, in __enter__
return next(self.gen)
File "C:\Users\jrf\AppData\Local\Programs\Python\Python310\lib\importlib\_common.py", line 95, in _tempfile
os.remove(raw_path)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\jrf\\AppData\\Local\\Temp\\tmp23ldltgt'
PS C:\Script\Frost_met>
PS C:\Script\Frost_met> & 'C:\Users\jrf\AppData\Local\Programs\Python\Python310\python.exe' 'c:\Users\jrf\.vscode\extensions\ms-python.python-2022.12.0\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher' '62406' '--' 'c:\Script\Frost_met\frost.py'
Traceback (most recent call last):
File "C:\Users\jrf\AppData\Local\Programs\Python\Python310\lib\importlib\_common.py", line 89, in _tempfile
os.write(fd, reader())
File "C:\Users\jrf\AppData\Local\Programs\Python\Python310\lib\importlib\abc.py", line 371, in read_bytes
with self.open('rb') as strm:
File "C:\Users\jrf\AppData\Local\Programs\Python\Python310\lib\importlib\_adapters.py", line 54, in open
raise ValueError()
ValueError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\Script\Frost_met\frost.py", line 4, in <module>
import requests
File "C:\Users\jrf\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\__init__.py", line 147, in <module>
from . import packages, utils
File "C:\Users\jrf\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\utils.py", line 24, in <module>
from . import certs
File "C:\Users\jrf\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\certs.py", line 14, in <module>
from certifi import where
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "C:\Users\jrf\AppData\Local\Programs\Python\Python310\lib\site-packages\wrapt\importer.py", line 177, in _exec_module
notify_module_loaded(module)
File "C:\Users\jrf\AppData\Local\Programs\Python\Python310\lib\site-packages\wrapt\decorators.py", line 470, in _synchronized
return wrapped(*args, **kwargs)
File "C:\Users\jrf\AppData\Local\Programs\Python\Python310\lib\site-packages\wrapt\importer.py", line 136, in notify_module_loaded
hook(module)
File "C:\Users\jrf\AppData\Local\Programs\Python\Python310\lib\site-packages\certifi_win32\wrapt_certifi.py", line 20, in apply_patches
certifi_win32.wincerts.CERTIFI_PEM = certifi.where()
File "C:\Users\jrf\AppData\Local\Programs\Python\Python310\lib\site-packages\certifi\core.py", line 37, in where
_CACERT_PATH = str(_CACERT_CTX.__enter__())
File "C:\Users\jrf\AppData\Local\Programs\Python\Python310\lib\contextlib.py", line 135, in __enter__
return next(self.gen)
File "C:\Users\jrf\AppData\Local\Programs\Python\Python310\lib\importlib\_common.py", line 95, in _tempfile
os.remove(raw_path)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\jrf\\AppData\\Local\\Temp\\tmp23ldltgt'
PS C:\Script\Frost_met>

Looks like the problem comes from python-certifi-win32, as seen in the error messages. To solve it use the link below there are solutions for python-certifi-win32 problem.
python-certifi-win32 problem with solutions
If these solutions don't work search for python-certifi-win32 uninstall and install process.
Last but not recommended solution uninstall all python files and libraries delete config files, caches and all files related to python and reinstall.

I was running into the same problem, but the error was intermittent. If you are coding your file open/close correctly and still running into this error, make sure you are not synching the files with Dropbox, Google Drive, etc. I paused Dropbox and I no longer see the error.

Related

Fail to import excel file

I was trying to import excel file into python, here is my code :
import pandas as pd
df = pd.read_excel('Sales.xlsx')
print(df)
somehow, i get a list of error and i have no idea how to fix it
Traceback (most recent call last):
File "C:\Users\wongs\AppData\Local\Programs\Python\Python311\Lib\site-packages\pandas\compat\_optional.py", line 141, in import_optional_dependency
module = importlib.import_module(name)
File "C:\Users\wongs\AppData\Local\Programs\Python\Python311\Lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
File "<frozen importlib._bootstrap>", line 1142, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'openpyxl'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\wongs\OneDrive\Desktop\utar\y2s3\data mining\P2 TASK 3.py", line 3, in <module>
df = pd.read_excel('Sales.xlsx')
File "C:\Users\wongs\AppData\Local\Programs\Python\Python311\Lib\site-packages\pandas\util\_decorators.py", line 211, in wrapper
return func(*args, **kwargs)
File "C:\Users\wongs\AppData\Local\Programs\Python\Python311\Lib\site-packages\pandas\util\_decorators.py", line 331, in wrapper
return func(*args, **kwargs)
File "C:\Users\wongs\AppData\Local\Programs\Python\Python311\Lib\site-packages\pandas\io\excel\_base.py", line 482, in read_excel
io = ExcelFile(io, storage_options=storage_options, engine=engine)
File "C:\Users\wongs\AppData\Local\Programs\Python\Python311\Lib\site-packages\pandas\io\excel\_base.py", line 1695, in __init__
self._reader = self._engines[engine](self._io, storage_options=storage_options)
File "C:\Users\wongs\AppData\Local\Programs\Python\Python311\Lib\site-packages\pandas\io\excel\_openpyxl.py", line 556, in __init__
import_optional_dependency("openpyxl")
File "C:\Users\wongs\AppData\Local\Programs\Python\Python311\Lib\site-packages\pandas\compat\_optional.py", line 144, in import_optional_dependency
raise ImportError(msg)
ImportError: Missing optional dependency 'openpyxl'. Use pip or conda to install openpyxl.
Your code is fine but there is openpyxl package missing.
Install it using command : !pip install openpyxl
run the above command in your command prompt and then run your code hope it will work fine.

pip freeze throws an exception

I am using Python 3.11.0 on Windows 10. I was able to successfully create a virtual environment with a requirements file. My pip.ini has references to my company's repository.
When I ran pip freeze it threw an exception.
My minimal requirements file is as follows:
asc-security-python
derf-api-catalog
flask
flask-restx
gevent
openpyxl
pandas
pytest
pytest-xdist
requests-negotiate-sspi
sqlalchemy-pyodbc-mssql
waitress
xlsxwriter
The detailed steps are as follows:
%USERPROFILE%\Python\python -m venv %USERPROFILE%\envs\MyEnv
%USERPROFILE%\envs\MyEnv\Scripts\activate
cd %USERPROFILE%\MyProject
pip install -r myrequirements.txt
pip freeze
The exception thrown is as follows:
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "C:\Users\johndoe\envs\MyEnv\Scripts\pip.exe\__main__.py", line 4, in <module>
File "C:\Users\johndoe\envs\MyEnv\Lib\site-packages\pip\_internal\cli\main.py", line 9, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "C:\Users\johndoe\envs\MyEnv\Lib\site-packages\pip\_internal\cli\autocompletion.py", line 10, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "C:\Users\johndoe\envs\MyEnv\Lib\site-packages\pip\_internal\cli\main_parser.py", line 9, in <module>
from pip._internal.build_env import get_runnable_pip
File "C:\Users\johndoe\envs\MyEnv\Lib\site-packages\pip\_internal\build_env.py", line 20, in <module>
from pip._internal.cli.spinners import open_spinner
File "C:\Users\johndoe\envs\MyEnv\Lib\site-packages\pip\_internal\cli\spinners.py", line 9, in <module>
from pip._internal.utils.logging import get_indentation
File "C:\Users\johndoe\envs\MyEnv\Lib\site-packages\pip\_internal\utils\logging.py", line 29, in <module>
from pip._internal.utils.misc import ensure_dir
File "C:\Users\johndoe\envs\MyEnv\Lib\site-packages\pip\_internal\utils\misc.py", line 41, in <module>
from pip._internal.exceptions import CommandError
File "C:\Users\johndoe\envs\MyEnv\Lib\site-packages\pip\_internal\exceptions.py", line 13, in <module>
from pip._vendor.requests.models import Request, Response
File "C:\Users\johndoe\envs\MyEnv\Lib\site-packages\pip\_vendor\requests\__init__.py", line 149, in <module>
from . import packages, utils
File "C:\Users\johndoe\envs\MyEnv\Lib\site-packages\pip\_vendor\requests\utils.py", line 24, in <module>
from . import certs
File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
File "C:\Users\johndoe\envs\MyEnv\Lib\site-packages\wrapt\importer.py", line 177, in _exec_module
notify_module_loaded(module)
File "C:\Users\johndoe\envs\MyEnv\Lib\site-packages\wrapt\decorators.py", line 470, in _synchronized
return wrapped(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\johndoe\envs\MyEnv\Lib\site-packages\wrapt\importer.py", line 136, in notify_module_loaded
hook(module)
File "C:\Users\johndoe\envs\MyEnv\Lib\site-packages\certifi_win32\wrapt_pip.py", line 35, in apply_patches
import certifi
File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
File "C:\Users\johndoe\envs\MyEnv\Lib\site-packages\wrapt\importer.py", line 177, in _exec_module
notify_module_loaded(module)
File "C:\Users\johndoe\envs\MyEnv\Lib\site-packages\wrapt\decorators.py", line 470, in _synchronized
return wrapped(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\johndoe\envs\MyEnv\Lib\site-packages\wrapt\importer.py", line 136, in notify_module_loaded
hook(module)
File "C:\Users\johndoe\envs\MyEnv\Lib\site-packages\certifi_win32\wrapt_certifi.py", line 20, in apply_patches
certifi_win32.wincerts.CERTIFI_PEM = certifi.where()
^^^^^^^^^^^^^^^
File "C:\Users\johndoe\envs\MyEnv\Lib\site-packages\certifi\core.py", line 37, in where
_CACERT_PATH = str(_CACERT_CTX.__enter__())
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\johndoe\Python\Lib\contextlib.py", line 137, in __enter__
return next(self.gen)
^^^^^^^^^^^^^^
File "C:\Users\johndoe\Python\Lib\importlib\resources\_common.py", line 80, in _tempfile
os.write(fd, reader())
^^^^^^^^
File "C:\Users\johndoe\Python\Lib\importlib\resources\abc.py", line 76, in read_bytes
with self.open('rb') as strm:
^^^^^^^^^^^^^^^
File "C:\Users\johndoe\Python\Lib\importlib\resources\_adapters.py", line 141, in open
raise FileNotFoundError("Can't open orphan path")
FileNotFoundError: Can't open orphan path
Is there a fix for the issue that will allow me to generate a detailed requirements.txt showing all dependencies?

PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: after installing python-certifi-win32

I installed python-certifi-win32 package and after that, I am getting below error, when I import anything or pip install anything, the fail with the final error of PermissionError.
I tried rebooting the box. It didn't work. I am unable to uninstall the package as pip is erroring out too.
I am unable to figure out the exact reason why this error is happening. It doesn't seem to be code specific, seems related to the library I installed
PS C:\Users\visha\PycharmProjects\master_test_runner> pip install python-certifi-win32
Traceback (most recent call last):
File "C:\Users\visha\AppData\Local\Programs\Python\Python310\lib\importlib\_common.py", line 89, in _tempfile
os.write(fd, reader())
File "C:\Users\visha\AppData\Local\Programs\Python\Python310\lib\importlib\abc.py", line 371, in read_bytes
with self.open('rb') as strm:
File "C:\Users\visha\AppData\Local\Programs\Python\Python310\lib\importlib\_adapters.py", line 54, in open
raise ValueError()
ValueError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\visha\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\visha\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Users\visha\PycharmProjects\GUI_Automation\venv\Scripts\pip.exe\__main__.py", line 4, in <module>
File "C:\Users\visha\PycharmProjects\GUI_Automation\venv\lib\site-packages\pip\_internal\cli\main.py", line 9, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "C:\Users\visha\PycharmProjects\GUI_Automation\venv\lib\site-packages\pip\_internal\cli\autocompletion.py", line 10, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "C:\Users\visha\PycharmProjects\GUI_Automation\venv\lib\site-packages\pip\_internal\cli\main_parser.py", line 8, in <module>
from pip._internal.cli import cmdoptions
File "C:\Users\visha\PycharmProjects\GUI_Automation\venv\lib\site-packages\pip\_internal\cli\cmdoptions.py", line 23, in <module>
from pip._internal.cli.parser import ConfigOptionParser
File "C:\Users\visha\PycharmProjects\GUI_Automation\venv\lib\site-packages\pip\_internal\cli\parser.py", line 12, in <module>
from pip._internal.configuration import Configuration, ConfigurationError
File "C:\Users\visha\PycharmProjects\GUI_Automation\venv\lib\site-packages\pip\_internal\configuration.py", line 21, in <module>
from pip._internal.exceptions import (
File "C:\Users\visha\PycharmProjects\GUI_Automation\venv\lib\site-packages\pip\_internal\exceptions.py", line 8, in <module>
from pip._vendor.requests.models import Request, Response
File "C:\Users\visha\PycharmProjects\GUI_Automation\venv\lib\site-packages\pip\_vendor\requests\__init__.py", line 123, in <module>
from . import utils
File "C:\Users\visha\PycharmProjects\GUI_Automation\venv\lib\site-packages\pip\_vendor\requests\utils.py", line 25, in <module>
from . import certs
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "C:\Users\visha\PycharmProjects\GUI_Automation\venv\lib\site-packages\wrapt\importer.py", line 170, in exec_module
notify_module_loaded(module)
File "C:\Users\visha\PycharmProjects\GUI_Automation\venv\lib\site-packages\wrapt\decorators.py", line 470, in _synchronized
return wrapped(*args, **kwargs)
File "C:\Users\visha\PycharmProjects\GUI_Automation\venv\lib\site-packages\wrapt\importer.py", line 136, in notify_module_loaded
hook(module)
File "C:\Users\visha\PycharmProjects\GUI_Automation\venv\lib\site-packages\certifi_win32\wrapt_pip.py", line 35, in apply_patches
import certifi
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "C:\Users\visha\PycharmProjects\GUI_Automation\venv\lib\site-packages\wrapt\importer.py", line 170, in exec_module
notify_module_loaded(module)
File "C:\Users\visha\PycharmProjects\GUI_Automation\venv\lib\site-packages\wrapt\decorators.py", line 470, in _synchronized
return wrapped(*args, **kwargs)
File "C:\Users\visha\PycharmProjects\GUI_Automation\venv\lib\site-packages\wrapt\importer.py", line 136, in notify_module_loaded
hook(module)
File "C:\Users\visha\PycharmProjects\GUI_Automation\venv\lib\site-packages\certifi_win32\wrapt_certifi.py", line 20, in apply_patches
certifi_win32.wincerts.CERTIFI_PEM = certifi.where()
File "C:\Users\visha\PycharmProjects\GUI_Automation\venv\lib\site-packages\certifi\core.py", line 37, in where
_CACERT_PATH = str(_CACERT_CTX.__enter__())
File "C:\Users\visha\AppData\Local\Programs\Python\Python310\lib\contextlib.py", line 135, in __enter__
return next(self.gen)
File "C:\Users\visha\AppData\Local\Programs\Python\Python310\lib\importlib\_common.py", line 95, in _tempfile
os.remove(raw_path)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\visha\\AppData\\Local\\Temp\\tmpy_tb8siv'
PS C:\Users\visha\PycharmProjects\master_test_runner>
I ran into the same issue today. I corrected it by removing two *.pth files that were created when I had installed python-certifi-win32. This prevents python-certifi-win32 from loading when python is run.
The files are listed below, and were located here:
C:\Users\<username>\AppData\Local\Programs\Python\Python310\Lib\site-packages
Files:
python-certifi-win32-init.pth
distutils-precedence.pth
Removing these files allowed me to install/uninstall other modules.
Andrew Leech, the author of python-certifi-win32, suggests to move on to his other project pip-system-certs (PyPI link). Drop-in replacing python-certifi-win32 with pip-system-certs solved all issues for me.
While the solution provided in this answer prevented the in the question mentioned error message for me too, it came with the side effect that my Python script didn't use the certificates in the Windows certificate store anymore, resulting again in SSL certificate errors - rendering the use of the library useless.

Execute file in specific path bash

i'm using Stacoan for vulnerability analysis (https://github.com/vincentcox/StaCoAn), i want to use it in a pipeline, but when i run stacoan binary or python script in other path, i obtain errors (using stacoan.py):
Traceback (most recent call last):
File "/home/jenkins/StaCoAn/src/stacoan.py", line 18, in <module>
from helpers.project import Project
File "/home/jenkins/StaCoAn/src/helpers/project.py", line 11, in <module>
from helpers.file import File
File "/home/jenkins/StaCoAn/src/helpers/file.py", line 12, in <module>
class File:
File "/home/jenkins/StaCoAn/src/helpers/file.py", line 15, in File
non_regex_indicator = config.get("ProgramConfig", 'non_regex_indicator')
File "/usr/lib/python3.8/configparser.py", line 781, in get
d = self._unify_values(section, vars)
File "/usr/lib/python3.8/configparser.py", line 1149, in _unify_values
raise NoSectionError(section) from None
configparser.NoSectionError: No section: 'ProgramConfig'
Using stacoan executable:
Traceback (most recent call last):
File "/opt/python/3.6.2/lib/python3.6/configparser.py", line 1138, in _unify_values
KeyError: 'ProgramConfig'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/travis/build/vincentcox/StaCoAn/src/stacoan.py", line 17, in <module>
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "/home/travis/virtualenv/python3.6.2/lib/python3.6/site-packages/PyInstaller/loader/pyimod03_importers.py", line 627, in exec_module
File "/home/travis/build/vincentcox/StaCoAn/src/logger.py", line 19, in <module>
File "/home/travis/build/vincentcox/StaCoAn/src/logger.py", line 25, in Logger
File "/home/travis/build/vincentcox/StaCoAn/src/logger.py", line 41, in __Logger
File "/opt/python/3.6.2/lib/python3.6/configparser.py", line 781, in get
File "/opt/python/3.6.2/lib/python3.6/configparser.py", line 1141, in _unify_values
configparser.NoSectionError: No section: 'ProgramConfig'
[81859] Failed to execute script stacoan
This doesn't occurs if i run it in its own path, i tried a simbolic link, executing using absolute path and build an executable but i still obtains errors.
Thanks!
NOTE: I know is a deprecated repository, but my team want to use it
You could use:
os.chdir(path)
More details here: https://www.geeksforgeeks.org/python-os-chdir-method/

not showing the server address while using python manage.py runserver in django

while running python manage.py runserver , getting this error as given below. using pycharm
(venv) C:\Users\User\PycharmProjects\PyShop>python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Users\User\PycharmProjects\PyShop\venv\lib\site-packages\django\template\utils.py",
line 66, in __getitem__
return self._engines[alias]
KeyError: 'django'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\User\PycharmProjects\PyShop\venv\lib\site-packages\django\template\backends\d
jango.py", line 121, in get_package_libraries
module = import_module(entry[1])
File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\importlib\__init__.py", li
ne 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 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\User\PycharmProjects\PyShop\venv\lib\site-packages\django\contrib\admin\templ
atetags\admin_static.py", line 5, in <module>
from django.utils.deprecation import RemovedInDjango30Warning
ImportError: cannot import name 'RemovedInDjango30Warning' from 'django.utils.deprecation' (C:
\Users\User\PycharmProjects\PyShop\venv\lib\site-packages\django\utils\deprecation.py)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\threading.py", line 917, i
n _bootstrap_inner
self.run()
File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\threading.py", line 865, i
n run
self._target(*self._args, **self._kwargs)
File "C:\Users\User\PycharmProjects\PyShop\venv\lib\site-packages\django\utils\autoreload.py
", line 53, in wrapper
fn(*args, **kwargs)
File "C:\Users\User\PycharmProjects\PyShop\venv\lib\site-packages\django\core\management\com
mands\runserver.py", line 118, in inner_run
self.check(display_num_errors=True)
File "C:\Users\User\PycharmProjects\PyShop\venv\lib\site-packages\django\core\management\bas
e.py", line 396, in check
databases=databases,
File "C:\Users\User\PycharmProjects\PyShop\venv\lib\site-packages\django\core\checks\registr
y.py", line 70, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
File "C:\Users\User\PycharmProjects\PyShop\venv\lib\site-packages\django\contrib\admin\check
s.py", line 78, in check_dependencies
for engine in engines.all():
File "C:\Users\User\PycharmProjects\PyShop\venv\lib\site-packages\django\template\utils.py",
line 90, in all
return [self[alias] for alias in self]
File "C:\Users\User\PycharmProjects\PyShop\venv\lib\site-packages\django\template\utils.py",
line 90, in <listcomp>
return [self[alias] for alias in self]
File "C:\Users\User\PycharmProjects\PyShop\venv\lib\site-packages\django\template\utils.py",
line 81, in __getitem__
engine = engine_cls(params)
File "C:\Users\User\PycharmProjects\PyShop\venv\lib\site-packages\django\template\backends\d
jango.py", line 25, in __init__
options['libraries'] = self.get_templatetag_libraries(libraries)
File "C:\Users\User\PycharmProjects\PyShop\venv\lib\site-packages\django\template\backends\d
jango.py", line 43, in get_templatetag_libraries
libraries = get_installed_libraries()
File "C:\Users\User\PycharmProjects\PyShop\venv\lib\site-packages\django\template\backends\d
jango.py", line 108, in get_installed_libraries
for name in get_package_libraries(pkg):
File "C:\Users\User\PycharmProjects\PyShop\venv\lib\site-packages\django\template\backends\d
jango.py", line 125, in get_package_libraries
"trying to load '%s': %s" % (entry[1], e)
django.template.library.InvalidTemplateLibrary: Invalid template library specified. ImportErro
r raised when trying to load 'django.contrib.admin.templatetags.admin_static': cannot import n
ame 'RemovedInDjango30Warning' from 'django.utils.deprecation' (C:\Users\User\PycharmProjects\
PyShop\venv\lib\site-packages\django\utils\deprecation.py)
This is caused by django versions. You probably upgraded it or something
There is a conflicts in Django versions as you can see in your error
ImportError: cannot import name 'RemovedInDjango30Warning'
So you can try to create a virtual environment and first uninstall and then re install
pip uninstall django
and then install another version lower then 3.0
pip install django==2.2

Categories

Resources