skaai
skaai

Reputation: 101

pipenv shell vs pipenv run (with scripts)

While following this tutorial by tds,I decided to do it through pipenv since I'm on macos. I managed to get most done, but I kept running into an error that suggests I don't understand how pipenv sets up an environment. Specifically, with how it runs scripts. It seems to revert to relying on my system python (2.7) even from within the pipenv shell. (the parse_gpx.py is the main python file while the 2021-0622run.gpx is the gpx format file that will be analyzed)

Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pandas/__init__.py", line 25, in <module>
    from pandas import hashtable, tslib, lib
ImportError: dlopen(/Library/Python/2.7/site-packages/pandas/hashtable.so, 2): Symbol not found: _PyCObject_Type
  Referenced from: /Library/Python/2.7/site-packages/pandas/hashtable.so
  Expected in: flat namespace
 in /Library/Python/2.7/site-packages/pandas/hashtable.so

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "parse_gpx.py", line 5, in <module>
    import pandas as pd
  File "/Library/Python/2.7/site-packages/pandas/__init__.py", line 31, in <module>
    "extensions first.".format(module))
ImportError: C extension: dlopen(/Library/Python/2.7/site-packages/pandas/hashtable.so, 2): Symbol not found: _PyCObject_Type
  Referenced from: /Library/Python/2.7/site-packages/pandas/hashtable.so
  Expected in: flat namespace
 in /Library/Python/2.7/site-packages/pandas/hashtable.so not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --inplace' to build the C extensions first.

my question is: why does it appear that "pipenv shell" looks in the system python rather than staying in its own "box?" wasn't that the whole point of pipenv? is it possible I configured something wrong? I did have a few problems setting it up (including double installs and other things) which is why I'm not sure if this behavior is by design, or a remnant of my previous botched installs.

Any help pointing me to documentation that explains what is going on would be appreciated!

And finally, sorry if this is in the wrong place. I tried looking for the best place to ask this and also checked if anyone had asked this before.

Thank you!

Upvotes: 0

Views: 928

Answers (1)

Marlon Richert
Marlon Richert

Reputation: 7020

First of all, have you also installed PyEnv? Without PyEnv, PipEnv cannot install the required Python version for you.

Secondly, when you created your environment, did you remember to specify the Python version? To create an environment with the latest Python 3 release, use pipenv --three.

Upvotes: 0

Related Questions