4

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!

A.Student
  • 41
  • 2
  • Before you run `pip`, start a Windows console session as Administrator. If the install was "for all users", then the uninstall must be also, and that requires elevated permissions. – BoarGules Mar 23 '22 at 07:31
  • I am having the same issues. The way I could replicate is by running `pip install arcgis` in any environment. If it's a virtual environment the only way I've found to get a working environment is to fully remove the environment and recreate it. If it's the main environment the only way I was able to 'recover' was by uninstalling Python, removing the `Lib` folder and reinstalling Python. It broke both Python 3.10.2 and 3.7.9 for me. In both `pip list` broke as well as `import arcgis` and `import requests`. In 3.7.9 `pip` and `pip freeze` remained functional however. – Freek Mar 24 '22 at 16:27
  • I also found that installing `arcgis` with the `--no-deps` flag doesn't break the environment, so the problem seems to be located with one of the dependencies. – Freek Mar 24 '22 at 16:28
  • I wonder if using a Conda environment in PyCharm might help deal with the dependency issues; the packages--or their dependencies--keep breaking environments. I do need a few packages to work together: arcgis, Fiona, Pandas, and perhaps a few others. I'm currently watching some YouTube videos to get a better bearing on what Anaconda is, and how it might work with PyCharm. Maybe that'll lead somewhere... – A.Student Mar 26 '22 at 01:47
  • I got the same error, but with different packages. I found out that it only happens in Python 3.10. Python 3.9 works fine. From what I see in your logs, the main suspect is [`python-certifi-win32`](https://pypi.org/project/python-certifi-win32/), which is one of the packages I also have in my environment. – sourcream Jun 23 '22 at 21:09
  • Python 3.9 is what I ended up with on one of the machines (I use both my personal computer and the work laptop for work), I think the other is using 3.7. Ultimately what I did was used Anaconda/Miniconda to create an environment and download the packages I needed all at once; that way Anaconda/Miniconda could make sure that all of the packages were "friends". It also helped to figure out that `Fiona` wasn't necessary for a Spatially Enabled Data Frame; `arcgis` and `arcpy` were all that were necessary. – A.Student Jun 25 '22 at 20:40

1 Answers1

0

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.)

Freek
  • 146
  • 7
  • The `cachetools`, `lxml`, and `requests-oauthlib` were helpful, thanks! On the whole, I went about it a little differently. I downloaded Anaconda (it's geared toward data analysis) and created a Conda Environment in PyCharm for the anaconda/python.exe file. It still threw a fuss about downloading the `arcgis` package, but the suggestion PyCharm had in the error message was to go here: [link](https://anaconda.org/) to find the package and copy/paste commands into the terminal. I have `arcgis` now, but `fiona` keeps returning: `ERROR 1: PROJ: proj_create_from_database: Cannot find proj.db` – A.Student Mar 28 '22 at 00:48