OceanParcels / Parcels

Main code for Parcels (Probably A Really Computationally Efficient Lagrangian Simulator)
https://www.oceanparcels.org
MIT License
295 stars 136 forks source link

Error with line 'from py import path' in Field.py #767

Closed pierrick-giffard closed 4 years ago

pierrick-giffard commented 4 years ago

Hi,

I use Parcels 2.1.4 and I'm getting an error while importing Field at line 16: from py import path. Honestly, I didn't understand really what is the module py... I tried to create a new environment but I had the same problem. Thanks for your help,

Pierrick

Traceback (most recent call last): File "/data/rd_exchange2/pgiffard/stamm/src/STAMM.py", line 15, in from parcels import plotTrajectoriesFile,ErrorCode File "/data/rd_exchange2/pgiffard/anaconda/envs/parcelstest/lib/python3.6/site-packages/parcels/init.py", line 4, in from parcels.fieldset import * # noqa File "/data/rd_exchange2/pgiffard/anaconda/envs/parcelstest/lib/python3.6/site-packages/parcels/fieldset.py", line 8, in from parcels.field import Field, DeferredArray File "/data/rd_exchange2/pgiffard/anaconda/envs/parcelstest/lib/python3.6/site-packages/parcels/field.py", line 16, in from py import path ModuleNotFoundError: No module named 'py'

erikvansebille commented 4 years ago

This seems a botched install. How did you install Parcels? Following the installation instructions on the oceanparcels.org website? Could you try again with a clean conda environment?

pierrick-giffard commented 4 years ago

Hi Erik, In a terminal, I did:

conda create -n py3_parcels -c conda-forge python=3.6 parcels jupyter cartopy ffmpeg
conda activate py3_parcels
import parcels

And I still get the same error. I use conda 4.8.2. I tried with an other computer and still get the same error.

erikvansebille commented 4 years ago

Hmm, this is strange. I was indeed able to replicate your Error, but had not experienced this before. It might be because perhaps py is not default installed in the latest conda version 4.8.2 anymore?

Anyways, a simple solution is to do

conda install py

That fixes this Issue for me. Let us know if it works!

willirath commented 4 years ago

Note that according to https://github.com/pytest-dev/py, py is maintenance only and should be avoided for future projects. The authors of py suggest using pathlib from the standad library instead of py.path.

erikvansebille commented 4 years ago

Thanks for the update @willirath! I will then create a PR soon that phases out py; should not be too hard for Parcels

pierrick-giffard commented 4 years ago

Thanks @willirath and @erikvansebille , conda install py does the job for now.

erikvansebille commented 4 years ago

Fixed in #770