0

System is configured as macOS 13.0.1 (Ventura), python 3.8.10, pyproj-3.4.0.

python is installed from python.org

>which python3.8
/Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8
>which proj
/usr/local/bin/proj

proj is version 9.1.1

>which pyproj
/Library/Frameworks/Python.framework/Versions/3.8/bin/pyproj

when I open the python3 shell from ~/ in terminal import works as expected:


Python 3.8.10 (v3.8.10:3d8993a744, May  3 2021, 08:55:58) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyproj
>>> 

when I open the python3 shell from ~/Desktop/ in terminal import pyproj fails:


Python 3.8.10 (v3.8.10:3d8993a744, May  3 2021, 08:55:58) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyproj
[[ 0.  1.  2.  3.  4.  5.  6.]
 [ 1.  2.  3.  4.  5.  6.  7.]
 [ 2.  3.  4.  5.  6.  7.  8.]
 [ 3.  4.  5.  6.  7.  8.  9.]
 [ 4.  5.  6.  7.  8.  9. 10.]
 [ 5.  6.  7.  8.  9. 10. 11.]
 [ 6.  7.  8.  9. 10. 11. 12.]
 [ 7.  8.  9. 10. 11. 12. 13.]
 [ 8.  9. 10. 11. 12. 13. 14.]
 [ 9. 10. 11. 12. 13. 14. 15.]]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pyproj/__init__.py", line 34, in <module>
    import pyproj.network
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pyproj/network.py", line 10, in <module>
    from pyproj._network import (  # noqa: F401 pylint: disable=unused-import
  File "pyproj/_network.pyx", line 1, in init pyproj._network
TypeError: array.array is not a type object
>>> 

I am running terminal with zsh shell

contents of .zprofile


export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
export PATH
# Setting PATH for Python 3.8
# The original version is saved in .zprofile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.8/bin:${PATH}"
export PATH

# Setting PATH for pyproj
PATH="/Library/Frameworks/Python.framework/Versions/3.8/bin/pyproj:${PATH}"
export PATH


When I check the $PATH:


> echo $PATH

/Library/Frameworks/Python.framework/Versions/3.8/bin/pyproj:/Library/Frameworks/Python.framework/Versions/3.8/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

Everything was working yesterday morning, before I did some messing around trying to fix a virtualenv issue when opening terminal shells, I also installed crc32c package via pip.


>pip3 install crc32c

but I don't think this caused the problem. It seems more likely trying to fix the virtualenv loading issue messed up the ~/.zprofile file, but I can't see how.

I'm sure it is a problem with the resource file ~/.zprofile but I'm not really knowledgeable about shell resource files and setting environment variables.

Thanks in advance for trying to help.

I have been slowly trying to rebuild a working ~/.zprofile. The above is what I have built, but I cannot seem to change the behavior of pyproj importing when I am in the ~/: home directory and not working when I am in ~/Desktop/: directory.

1 Answers1

0

I tried several variations of uninstalling and reinstalling python, pyenv, proj, pyproj, and numpy. Eventually I found a hidden folder in my Desktop folder that had been created by the python.org installer about the time that my problems started. I deleted that hidden folder and it solved my problem.

Currently, my python setup was created by the following:

installed Homebrew

installed pyenv

edited ~/.zprofile to set the Homebrew and pyenv environments correctly.

installed python 3.11.1 via pyenv

set pyenv shell 3.11.1

loaded the necessary packages:

python3 -m pip install pyproj

python3 -m pip install numpy

python3 -m pip install crc32c

import pyproj now works from my python working folder

Tyler2P
  • 2,324
  • 26
  • 22
  • 31