Pip is broken, gives PermissionError: [WinError 32] - python

I installed the python-certifi-win32 module (I'm so busy trying to fix this problem that I don't even remember why I originally installed it). Right after I installed it, though, I started getting this error when I run pip (extended error code below): PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\user1\\AppData\\Local\\Temp\\tmph93rz74c'
When I delete the file C:\\Users\\user1\\AppData\\Local\\Temp\\tmph93rz74c, another file pops up in its place, just with a different random combination of letters and numbers, and the error says the new file name instead.
I have no idea how to fix it, my pip hasn't been working for days. I've looked through tens of pages of google results.
Full error code:
Traceback (most recent call last):
File "C:\Users\user1\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\user1\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Users\user1\AppData\Local\Programs\Python\Python310\Scripts\pip.exe\__main__.py", line 4, in <module>
File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\cli\main.py", line 9, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "C:\Users\user1\AppData\Local\Programs\Python\Python310\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\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\cli\main_parser.py", line 8, in <module>
from pip._internal.cli import cmdoptions
File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\cli\cmdoptions.py", line 23, in <module>
from pip._internal.cli.parser import ConfigOptionParser
File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\cli\parser.py", line 12, in <module>
from pip._internal.configuration import Configuration, ConfigurationError
File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\configuration.py", line 20, in <module>
from pip._internal.exceptions import (
File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\exceptions.py", line 13, in <module>
from pip._vendor.requests.models import Request, Response
File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_vendor\requests\__init__.py", line 135, in <module>
from . import utils
File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_vendor\requests\utils.py", line 27, 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\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\wrapt\importer.py", line 170, in exec_module
notify_module_loaded(module)
File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\wrapt\decorators.py", line 470, in _synchronized
return wrapped(*args, **kwargs)
File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\wrapt\importer.py", line 136, in notify_module_loaded
hook(module)
File "C:\Users\user1\AppData\Local\Programs\Python\Python310\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\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\wrapt\importer.py", line 170, in exec_module
notify_module_loaded(module)
File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\wrapt\decorators.py", line 470, in _synchronized
return wrapped(*args, **kwargs)
File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\wrapt\importer.py", line 136, in notify_module_loaded
hook(module)
File "C:\Users\user1\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\user1\AppData\Local\Programs\Python\Python310\lib\site-packages\certifi\core.py", line 37, in where
_CACERT_PATH = str(_CACERT_CTX.__enter__())
File "C:\Users\user1\AppData\Local\Programs\Python\Python310\lib\contextlib.py", line 135, in __enter__
return next(self.gen)
File "C:\Users\user1\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\\user1\\AppData\\Local\\Temp\\tmph93rz74c'

I ran into the same problem after installing python-certifi-win32. I installed this package in the hope to solve errors caused by the self-signed certificate used by our SSL Inspection infrastructure.
To bring pip back to a running state remove python-certifi-win32 from the installation folder:
Determine the installation path for pip packages (source):
python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"
Switch to the folder and delete the package's files:
del python-certifi-win32-init.pth
rmdir /s/q python_certifi_win32-1.6.dist-info

I could observe the same error pattern when upgrading from Python 3.9 to Python 3.10. Somehow python-certifi-win32 seems to be malfunctioning in certain scenarios then.
Andrew Leech, the author of python-certifi-win32, suggests to move on to his other project pip-system-certs . Drop-in replacing the library with pip-system-certs (PyPI link) solved all issues for me.

the only solution to this problem is to delete Python from control panel.Then completely delete the Python folder from the address below
windows:
C:\Users\user1\AppData\Local\Programs\python
and linux base:
/bin/python3

Related

Pip crashes after installing bitbucket repo to site-packages

So I have two VM machines running windows 10, and one one of them I get a funky error after installing one of our site-packages.
Some info:
Python version Python 3.10.2 with latests pip is installed, and I also have git 2.16.2.
The repository/python lib requires python 3.10+.
I run this command on my machine:
pip install --upgrade git+ssh://git#bitbucket.ccd2.com:7999/pyt/jira
it installed at normal, but when I then run pip list I get the following error:
$ pip list
Traceback (most recent call last):
File "C:\Programs\Python\Python3102\lib\importlib\_common.py", line 89, in _te mpfile
os.write(fd, reader())
File "C:\Programs\Python\Python3102\lib\importlib\abc.py", line 371, in read_b ytes
with self.open('rb') as strm:
File "C:\Programs\Python\Python3102\lib\importlib\_adapters.py", line 54, in o pen
raise ValueError()
ValueError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Programs\Python\Python3102\lib\runpy.py", line 196, in _run_module_as _main
return _run_code(code, main_globals, None,
File "C:\Programs\Python\Python3102\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Programs\Python\Python3102\Scripts\pip.exe\__main__.py", line 4, in < module>
File "C:\Programs\Python\Python3102\lib\site-packages\pip\_internal\cli\main.p y", line 9, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "C:\Programs\Python\Python3102\lib\site-packages\pip\_internal\cli\autoco mpletion.py", line 10, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "C:\Programs\Python\Python3102\lib\site-packages\pip\_internal\cli\main_p arser.py", line 8, in <module>
from pip._internal.cli import cmdoptions
File "C:\Programs\Python\Python3102\lib\site-packages\pip\_internal\cli\cmdopt ions.py", line 23, in <module>
from pip._internal.cli.parser import ConfigOptionParser
File "C:\Programs\Python\Python3102\lib\site-packages\pip\_internal\cli\parser .py", line 12, in <module>
from pip._internal.configuration import Configuration, ConfigurationError
File "C:\Programs\Python\Python3102\lib\site-packages\pip\_internal\configurat ion.py", line 20, in <module>
from pip._internal.exceptions import (
File "C:\Programs\Python\Python3102\lib\site-packages\pip\_internal\exceptions .py", line 13, in <module>
from pip._vendor.requests.models import Request, Response
File "C:\Programs\Python\Python3102\lib\site-packages\pip\_vendor\requests\__i nit__.py", line 135, in <module>
from . import utils
File "C:\Programs\Python\Python3102\lib\site-packages\pip\_vendor\requests\uti ls.py", line 27, 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:\Programs\Python\Python3102\lib\site-packages\wrapt\importer.py", line 177, in _exec_module
notify_module_loaded(module)
File "C:\Programs\Python\Python3102\lib\site-packages\wrapt\decorators.py", li ne 470, in _synchronized
return wrapped(*args, **kwargs)
File "C:\Programs\Python\Python3102\lib\site-packages\wrapt\importer.py", line 136, in notify_module_loaded
hook(module)
File "C:\Programs\Python\Python3102\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:\Programs\Python\Python3102\lib\site-packages\wrapt\importer.py", line 177, in _exec_module
notify_module_loaded(module)
File "C:\Programs\Python\Python3102\lib\site-packages\wrapt\decorators.py", li ne 470, in _synchronized
return wrapped(*args, **kwargs)
File "C:\Programs\Python\Python3102\lib\site-packages\wrapt\importer.py", line 136, in notify_module_loaded
hook(module)
File "C:\Programs\Python\Python3102\lib\site-packages\certifi_win32\wrapt_cert ifi.py", line 20, in apply_patches
certifi_win32.wincerts.CERTIFI_PEM = certifi.where()
File "C:\Programs\Python\Python3102\lib\site-packages\certifi\core.py", line 3 7, in where
_CACERT_PATH = str(_CACERT_CTX.__enter__())
File "C:\Programs\Python\Python3102\lib\contextlib.py", line 135, in __enter__
return next(self.gen)
File "C:\Programs\Python\Python3102\lib\importlib\_common.py", line 95, in _te mpfile
os.remove(raw_path)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\77870\\AppData\\Local\\Temp\\2\\tmplh cnerdl'
I have no idea why it works on all other machines VM or my own PC, but this one VM machine has this problem.
I have reinstalled everything and tried different versions of python and git, but the same error occurs.
I think it looks like something is stuck maybe in the temp folder? or maybe I have an issue with something else that I don't know?
Because its in the Temp folder, maybe its just a leftover from a program. Try deleting it, but I would make a backup for in case things go wrong. However, because this is kinda risky, I would wait in case a better answer appears (I have too little rep to comment).
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:
%LOCALAPPDATA%\Programs\Python\Python310\Lib\site-packages
Files:
python-certifi-win32-init.pth
distutils-precedence.pth
Had a machine where everything was running so made a pip freeze > req.txt file to check every version one by one, and then I just tried to update all the pip list --outdated packages, and when wrapt was updated the problem occurred. Downgraded the version to wrapt==1.13.3 which one of the other machines was running and now everything works.

Can't Install/Uninstall Python Packages due to ValueError and PermissionError: [WinError 32]

I'm new to both Python and ArcGIS Pro; I'm just getting started and I'm trying to install a couple of Python packages in order to read, modify, and write Feature Class files using a Spatially Enabled DataFrame (SEDF). To do that, I need to install a couple of packages first. I've created a virtual environment in PyCharm, and was able to install a few packages, however, now when I try to install or uninstall any new packages, I get this error:
Traceback (most recent call last):
File "C:\Users\alexis\AppData\Local\Programs\Python\Python310\lib\importlib\_common.py", line 89, in _tempfile
os.write(fd, reader())
File "C:\Users\alexis\AppData\Local\Programs\Python\Python310\lib\importlib\abc.py", line 371, in read_bytes
with self.open('rb') as strm:
File "C:\Users\alexis\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:\Program Files\JetBrains\PyCharm Community Edition 2021.3.3\plugins\python-ce\helpers\packaging_tool.py", line 114, in main
do_install(pkgs)
File "C:\Program Files\JetBrains\PyCharm Community Edition 2021.3.3\plugins\python-ce\helpers\packaging_tool.py", line 59, in do_install
run_pip(['install'] + pkgs)
File "C:\Program Files\JetBrains\PyCharm Community Edition 2021.3.3\plugins\python-ce\helpers\packaging_tool.py", line 73, in run_pip
runpy.run_module(module_name, run_name='__main__', alter_sys=True)
File "C:\Users\alexis\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 209, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File "C:\Users\alexis\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 96, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "C:\Users\alexis\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Users\alexis\Documents\Wardrobe\Testvenv1\lib\site-packages\pip\__main__.py", line 29, in <module>
from pip._internal.cli.main import main as _main
File "C:\Users\alexis\Documents\Wardrobe\Testvenv1\lib\site-packages\pip\_internal\cli\main.py", line 9, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "C:\Users\alexis\Documents\Wardrobe\Testvenv1\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\alexis\Documents\Wardrobe\Testvenv1\lib\site-packages\pip\_internal\cli\main_parser.py", line 8, in <module>
from pip._internal.cli import cmdoptions
File "C:\Users\alexis\Documents\Wardrobe\Testvenv1\lib\site-packages\pip\_internal\cli\cmdoptions.py", line 23, in <module>
from pip._internal.cli.parser import ConfigOptionParser
File "C:\Users\alexis\Documents\Wardrobe\Testvenv1\lib\site-packages\pip\_internal\cli\parser.py", line 12, in <module>
from pip._internal.configuration import Configuration, ConfigurationError
File "C:\Users\alexis\Documents\Wardrobe\Testvenv1\lib\site-packages\pip\_internal\configuration.py", line 20, in <module>
from pip._internal.exceptions import (
File "C:\Users\alexis\Documents\Wardrobe\Testvenv1\lib\site-packages\pip\_internal\exceptions.py", line 13, in <module>
from pip._vendor.requests.models import Request, Response
File "C:\Users\alexis\Documents\Wardrobe\Testvenv1\lib\site-packages\pip\_vendor\requests\__init__.py", line 135, in <module>
from . import utils
File "C:\Users\alexis\Documents\Wardrobe\Testvenv1\lib\site-packages\pip\_vendor\requests\utils.py", line 27, 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\alexis\Documents\Wardrobe\Testvenv1\lib\site-packages\wrapt\importer.py", line 170, in exec_module
notify_module_loaded(module)
File "C:\Users\alexis\Documents\Wardrobe\Testvenv1\lib\site-packages\wrapt\decorators.py", line 470, in _synchronized
return wrapped(*args, **kwargs)
File "C:\Users\alexis\Documents\Wardrobe\Testvenv1\lib\site-packages\wrapt\importer.py", line 136, in notify_module_loaded
hook(module)
File "C:\Users\alexis\Documents\Wardrobe\Testvenv1\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\alexis\Documents\Wardrobe\Testvenv1\lib\site-packages\wrapt\importer.py", line 170, in exec_module
notify_module_loaded(module)
File "C:\Users\alexis\Documents\Wardrobe\Testvenv1\lib\site-packages\wrapt\decorators.py", line 470, in _synchronized
return wrapped(*args, **kwargs)
File "C:\Users\alexis\Documents\Wardrobe\Testvenv1\lib\site-packages\wrapt\importer.py", line 136, in notify_module_loaded
hook(module)
File "C:\Users\alexis\Documents\Wardrobe\Testvenv1\lib\site-packages\certifi_win32\wrapt_certifi.py", line 20, in apply_patches
certifi_win32.wincerts.CERTIFI_PEM = certifi.where()
File "C:\Users\alexis\Documents\Wardrobe\Testvenv1\lib\site-packages\certifi\core.py", line 37, in where
_CACERT_PATH = str(_CACERT_CTX.__enter__())
File "C:\Users\alexis\AppData\Local\Programs\Python\Python310\lib\contextlib.py", line 135, in __enter__
return next(self.gen)
File "C:\Users\alexis\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\\alexis\\AppData\\Local\\Temp\\tmp0nrmgsas'
So far I've tried:
~Giving PyCharm Administrator permissions
~Used pip in the terminal (I always get the same error message back regardless of how I try to install/uninstall packages)
~Tried downloading other packages (same error message)
~Restarting the computer/PyCharm
~Using ArcGIS Pro to create a cloned environment GDAL, Fiona, and other packages can be installed on. However Fiona never seems to install properly, so now I'm trying to use a virtual environment in PyCharm to run the packages necessary for a Spatially Enabled DataFrame
It seems like the computer is trying to say that somehow a file is open somewhere and must be closed before it can install/uninstall anything else. However, I'm not really sure how to do that, or what that file would even be.
Despite the ValueError and PermissionError, scripts still run just fine; I just can't install or uninstall anything.
In short, I have two problems at once: (1) the package Fiona never seems to install properly, and (2) now I'm stuck with a ValueError and PermissonError that keeps me from installing/uninstalling other packages.
I'm using Python 3.10.2, PyCharm 2021.3.3, and Windows 10, 64 bit.
I've been stuck on this problem for a while now. Any advice would be much appreciated!
I've had contact with the helpdesk of Esri and they recommended using conda instead of pip to install the package. That seems to have worked for me.
Since I also would like to get it working with just pip I was able to determine that the minimal install is an option although you need to install cachetools, lxml, and requests-oauthlib even though they aren't mentioned in the instructions. That allowed me to import arcgis so it seems to have worked. I haven't had a chance to take more time with it, but perhaps this solves it for you too.
Just as a reminder, in order to fix your installation of Python you'd need to reinstall Python, but remove the Lib folder in between the un- and re-installation. (Or delete and remake the virtual environment if you used that.)

Not able to create or import existing conda project in Pycharm

I am trying to create or open existing conda project in PyCharm. In both cases I get this error:
TypeError: LoadLibrary() argument 1 must be str, not None
I have Anaconda3 package installed (conda 4.7.5) on my Windows machine. I was able to use it successfully from Anaconda Prompt (create and use environments, install packages and create project). But every time I try to create a project in PyCharm by selecting "File -> New Project -> Scientific -> New environment using Conda" with Python 3.6 I am getting the error above while the project is being created.
Alternatively, when I open existing conda project (from Anaconda Prompt) in PyCharm and then trying to select conda as interpreter I am getting exact same error.
I have been trying to solve this problem for 3 hours: reading forums, installing older versions, trying miniconda instead. Is that the problem with PyCharm?
Edit: Attached full stack trace.
Traceback (most recent call last):
File "C:\Users\Eduard\Anaconda3\lib\site-packages\conda\exceptions.py", line 1043, in __call__
return func(*args, **kwargs)
File "C:\Users\Eduard\Anaconda3\lib\site-packages\conda\cli\main.py", line 84, in _main
exit_code = do_call(args, p)
File "C:\Users\Eduard\Anaconda3\lib\site-packages\conda\cli\conda_argparse.py", line 80, in do_call
module = import_module(relative_mod, __name__.rsplit('.', 1)[0])
File "C:\Users\Eduard\Anaconda3\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 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\Eduard\Anaconda3\lib\site-packages\conda\cli\main_create.py", line 10, in <module>
from .install import install
File "C:\Users\Eduard\Anaconda3\lib\site-packages\conda\cli\install.py", line 19, in <module>
from ..core.index import calculate_channel_urls, get_index
File "C:\Users\Eduard\Anaconda3\lib\site-packages\conda\core\index.py", line 9, in <module>
from .package_cache_data import PackageCacheData
File "C:\Users\Eduard\Anaconda3\lib\site-packages\conda\core\package_cache_data.py", line 15, in <module>
from conda_package_handling.api import InvalidArchiveError
File "C:\Users\Eduard\Anaconda3\lib\site-packages\conda_package_handling\api.py", line 3, in <module>
from libarchive.exception import ArchiveError as _LibarchiveArchiveError
File "C:\Users\Eduard\Anaconda3\lib\site-packages\libarchive\__init__.py", line 1, in <module>
from .entry import ArchiveEntry
File "C:\Users\Eduard\Anaconda3\lib\site-packages\libarchive\entry.py", line 6, in <module>
from . import ffi
File "C:\Users\Eduard\Anaconda3\lib\site-packages\libarchive\ffi.py", line 27, in <module>
libarchive = ctypes.cdll.LoadLibrary(libarchive_path)
File "C:\Users\Eduard\Anaconda3\lib\ctypes\__init__.py", line 434, in LoadLibrary
return self._dlltype(name)
File "C:\Users\Eduard\Anaconda3\lib\ctypes\__init__.py", line 356, in __init__
self._handle = _dlopen(self._name, mode)
TypeError: LoadLibrary() argument 1 must be str, not None
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Eduard\Anaconda3\Scripts\conda-script.py", line 12, in <module>
sys.exit(main())
File "C:\Users\Eduard\Anaconda3\lib\site-packages\conda\cli\main.py", line 150, in main
return conda_exception_handler(_main, *args, **kwargs)
File "C:\Users\Eduard\Anaconda3\lib\site-packages\conda\exceptions.py", line 1335, in conda_exception_handler
return_value = exception_handler(func, *args, **kwargs)
File "C:\Users\Eduard\Anaconda3\lib\site-packages\conda\exceptions.py", line 1046, in __call__
return self.handle_exception(exc_val, exc_tb)
File "C:\Users\Eduard\Anaconda3\lib\site-packages\conda\exceptions.py", line 1090, in handle_exception
return self.handle_unexpected_exception(exc_val, exc_tb)
File "C:\Users\Eduard\Anaconda3\lib\site-packages\conda\exceptions.py", line 1101, in handle_unexpected_exception
self.print_unexpected_error_report(error_report)
File "C:\Users\Eduard\Anaconda3\lib\site-packages\conda\exceptions.py", line 1171, in print_unexpected_error_report
from .cli.main_info import get_env_vars_str, get_main_info_str
File "C:\Users\Eduard\Anaconda3\lib\site-packages\conda\cli\main_info.py", line 19, in <module>
from ..core.index import _supplement_index_with_system
File "C:\Users\Eduard\Anaconda3\lib\site-packages\conda\core\index.py", line 9, in <module>
from .package_cache_data import PackageCacheData
File "C:\Users\Eduard\Anaconda3\lib\site-packages\conda\core\package_cache_data.py", line 15, in <module>
from conda_package_handling.api import InvalidArchiveError
File "C:\Users\Eduard\Anaconda3\lib\site-packages\conda_package_handling\api.py", line 7, in <module>
from .tarball import CondaTarBZ2 as _CondaTarBZ2
File "C:\Users\Eduard\Anaconda3\lib\site-packages\conda_package_handling\tarball.py", line 7, in <module>
import libarchive
File "C:\Users\Eduard\Anaconda3\lib\site-packages\libarchive\__init__.py", line 1, in <module>
from .entry import ArchiveEntry
File "C:\Users\Eduard\Anaconda3\lib\site-packages\libarchive\entry.py", line 6, in <module>
from . import ffi
File "C:\Users\Eduard\Anaconda3\lib\site-packages\libarchive\ffi.py", line 27, in <module>
libarchive = ctypes.cdll.LoadLibrary(libarchive_path)
File "C:\Users\Eduard\Anaconda3\lib\ctypes\__init__.py", line 434, in LoadLibrary
return self._dlltype(name)
File "C:\Users\Eduard\Anaconda3\lib\ctypes\__init__.py", line 356, in __init__
self._handle = _dlopen(self._name, mode)
TypeError: LoadLibrary() argument 1 must be str, not None
I was getting the same issue while making a conda environment through command prompt. I added this in my environment variables. It helped in my case. Maybe it can help you as well
Your path to anaconda folder/Anaconda3/library/bin

Pip attribute error fromtimestamp

I always get this error when I try to install a python module using pip (py -m pip install (whatever) )
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python35\lib\runpy.py", line 170, in _run_module_as_main
"__main__", mod_spec)
File "C:\Users\user\AppData\Local\Programs\Python\Python35\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\user\AppData\Local\Programs\Python\Python35\lib\site-packages\pip\__main__.py", line 16, in <module>
from pip._internal import main as _main # noqa
File "C:\Users\user\AppData\Local\Programs\Python\Python35\lib\site-packages\pip\_internal\__init__.py", line 20, in <module>
from pip._vendor.urllib3.exceptions import DependencyWarning
File "C:\Users\user\AppData\Local\Programs\Python\Python35\lib\site-packages\pip\_vendor\urllib3\__init__.py", line 8, in <module>
from .connectionpool import (
File "C:\Users\user\AppData\Local\Programs\Python\Python35\lib\site-packages\pip\_vendor\urllib3\connectionpool.py", line 11, in <module>
from .exceptions import (
File "C:\Users\user\AppData\Local\Programs\Python\Python35\lib\site-packages\pip\_vendor\urllib3\exceptions.py", line 2, in <module>
from .packages.six.moves.http_client 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 664, in _load_unlocked
File "<frozen importlib._bootstrap>", line 634, in _load_backward_compatible
File "C:\Users\user\AppData\Local\Programs\Python\Python35\lib\site-packages\pip\_vendor\urllib3\packages\six.py", line 203, in load_module
mod = mod._resolve()
File "C:\Users\user\AppData\Local\Programs\Python\Python35\lib\site-packages\pip\_vendor\urllib3\packages\six.py", line 115, in _resolve
return _import_module(self.mod)
File "C:\Users\user\AppData\Local\Programs\Python\Python35\lib\site-packages\pip\_vendor\urllib3\packages\six.py", line 82, in _import_module
__import__(name)
File "C:\Users\user\AppData\Local\Programs\Python\Python35\lib\http\client.py", line 71, in <module>
import email.parser
File "C:\Users\user\AppData\Local\Programs\Python\Python35\lib\email\parser.py", line 12, in <module>
from email.feedparser import FeedParser, BytesFeedParser
File "C:\Users\userAppData\Local\Programs\Python\Python35\lib\email\feedparser.py", line 27, in <module>
from email import message
File "C:\Users\user\AppData\Local\Programs\Python\Python35\lib\email\message.py", line 16, in <module>
from email import utils
File "C:\Users\user\AppData\Local\Programs\Python\Python35\lib\email\utils.py", line 30, in <module>
import datetime
File "C:\Users\user\Desktop\datetime.py", line 10, in <module>
date = datetime.datetime.fromtimestamp(str(['positionTS']) / 1e3)
AttributeError: module 'datetime' has no attribute 'fromtimestamp'
I've tried several options from here to fix it but each results in the same error. I am wondering if I need to uninstall then re-install, possibly with an older version.
All help appreciated.
This looks very similar to a problem I have seen (and answered already). Looks like you have either a module or a Python program that's names the same as a system module: datetime.py (I see "C:\Users\user\Desktop\datetime.py" in your stack trace).
There are many situations when this can lead to problems and should be avoided.
See here for another example of the same situation:
ModuleNotFoundError: No module named 'tensorflow.contrib'; 'tensorflow' is not a package

sqlite and pyvenv and django

I am new to both python and django. I am trying to get python 3.4 and django 1.6.4 working within a pyvenv-3.4 environment on Linux Mint Mate 13. I followed the procedures of Using a virtual environment with Python 3.4 for "Building Python 3.4 from source" and "Using pyvenv-3.4". Then following the Django tutorial at Writing your first Django app, I was able to create "mysite" with startproject. But the command "python manage.py runserver" failed with
django.core.exceptions.
ImproperlyConfigured: Error loading either pysqlite2 or sqlite3 modules
(tried in that order):
No module named '_sqlite3'
Sorry, I do not recall why I resorted to compiling from source, but it may be that I was unable to find pyvenv in the standard Ubuntu downloads using apt-get. In any case, the Makefile for the source distribution does not have an "uninstall" target, so it seems I am stuck with whatever make installed, and without a plan for what to do next to actually get pyvenv-python-django working.
I am updating this post by attaching the full error:
$ python manage.py runserver
Traceback (most recent call last):
File "/local/djenv/lib/python3.4/site-packages/django/db/backends/sqlite3/base.py", line 30, in <module>
from pysqlite2 import dbapi2 as Database
ImportError: No module named 'pysqlite2'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/local/djenv/lib/python3.4/site-packages/django/db/backends/sqlite3/base.py", line 32, in <module>
from sqlite3 import dbapi2 as Database
File "/usr/local/lib/python3.4/sqlite3/__init__.py", line 23, in <module>
from sqlite3.dbapi2 import *
File "/usr/local/lib/python3.4/sqlite3/dbapi2.py", line 26, in <module>
from _sqlite3 import *
ImportError: No module named '_sqlite3'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/local/djenv/lib/python3.4/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/local/djenv/lib/python3.4/site-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/local/djenv/lib/python3.4/site-packages/django/core/management/base.py", line 242, in run_from_argv
self.execute(*args, **options.__dict__)
File "/local/djenv/lib/python3.4/site-packages/django/core/management/base.py", line 280, in execute
translation.activate('en-us')
File "/local/djenv/lib/python3.4/site-packages/django/utils/translation/__init__.py", line 130, in activate
return _trans.activate(language)
File "/local/djenv/lib/python3.4/site-packages/django/utils/translation/trans_real.py", line 188, in activate
_active.value = translation(language)
File "/local/djenv/lib/python3.4/site-packages/django/utils/translation/trans_real.py", line 177, in translation
default_translation = _fetch(settings.LANGUAGE_CODE)
File "/local/djenv/lib/python3.4/site-packages/django/utils/translation/trans_real.py", line 159, in _fetch
app = import_module(appname)
File "/usr/local/lib/python3.4/importlib/__init__.py", line 104, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2231, in _gcd_import
File "<frozen importlib._bootstrap>", line 2214, in _find_and_load
File "<frozen importlib._bootstrap>", line 2203, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1129, in _exec
File "<frozen importlib._bootstrap>", line 1448, in exec_module
File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
File "/local/djenv/lib/python3.4/site-packages/django/contrib/admin/__init__.py", line 6, in <module>
from django.contrib.admin.sites import AdminSite, site
File "/local/djenv/lib/python3.4/site-packages/django/contrib/admin/sites.py", line 4, in <module>
from django.contrib.admin.forms import AdminAuthenticationForm
File "/local/djenv/lib/python3.4/site-packages/django/contrib/admin/forms.py", line 6, in <module>
from django.contrib.auth.forms import AuthenticationForm
File "/local/djenv/lib/python3.4/site-packages/django/contrib/auth/forms.py", line 17, in <module>
from django.contrib.auth.models import User
File "/local/djenv/lib/python3.4/site-packages/django/contrib/auth/models.py", line 48, in <module>
class Permission(models.Model):
File "/local/djenv/lib/python3.4/site-packages/django/db/models/base.py", line 96, in __new__
new_class.add_to_class('_meta', Options(meta, **kwargs))
File "/local/djenv/lib/python3.4/site-packages/django/db/models/base.py", line 264, in add_to_class
value.contribute_to_class(cls, name)
File "/local/djenv/lib/python3.4/site-packages/django/db/models/options.py", line 124, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "/local/djenv/lib/python3.4/site-packages/django/db/__init__.py", line 34, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/local/djenv/lib/python3.4/site-packages/django/db/utils.py", line 198, in __getitem__
backend = load_backend(db['ENGINE'])
File "/local/djenv/lib/python3.4/site-packages/django/db/utils.py", line 113, in load_backend
return import_module('%s.base' % backend_name)
File "/usr/local/lib/python3.4/importlib/__init__.py", line 104, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/local/djenv/lib/python3.4/site-packages/django/db/backends/sqlite3/base.py", line 35, in <module>
raise ImproperlyConfigured("Error loading either pysqlite2 or sqlite3 modules (tried in that order): %s" % exc)
django.core.exceptions.ImproperlyConfigured: Error loading either pysqlite2 or sqlite3 modules (tried in that order): No module named '_sqlite3'
It sounds like you didn't have the SQLite development libraries installed at the time you built CPython from source. The build process conditionally includes some features based the availability of underlying development libraries.
On Debian GNU/Linux and derivatives, install libsqlite3-dev. Then re-run ./configure, make and make install.

Categories