econ-ark/HARK

cannot import name 'clock' from 'time'

Closed this issue · 15 comments

Describe the bug
When I try to load some of HARK using:

from HARK.distribution import (
    MeanOneLogNormal, 
    add_discrete_outcome_constant_mean
)

I get an error:

cannot import name 'clock' from 'time' (unknown location)

Expected behavior
I expected the packages to load, as they do when using Python 3.9

Desktop:

  • OS: MacOS Ventura
  • Econ-ARK and Python version 0.10.2 and python 3.10

Additional context
I believe the time.clock function is no longer supported starting with Python 3.8: https://stackoverflow.com/questions/65499013/importerror-cannot-import-name-clock-from-time-unknown-location

Hi @nomadj1s! Thanks for opening the issue, could you please update your HARK version? 0.10.2 is pretty old (~2.5 years).
That should solve this issue :)

Hi @nomadj1s! Thanks for opening the issue, could you please update your HARK version? 0.10.2 is pretty old (~2.5 years). That should solve this issue :)

Thanks for the help. When I install econ-ark using Conda, I only get the 10.2 version.

can you do the following:

conda install econ-ark=0.12

and report what you see?

This is what happens:

% conda install econ-ark=0.12
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.

PackagesNotFoundError: The following packages are not available from current channels:

  - econ-ark=0.12

Current channels:

  - https://repo.anaconda.com/pkgs/main/osx-64
  - https://repo.anaconda.com/pkgs/main/noarch
  - https://repo.anaconda.com/pkgs/r/osx-64
  - https://repo.anaconda.com/pkgs/r/noarch

To search for alternate channels that may provide the conda package you're
looking for, navigate to

    https://anaconda.org

and use the search bar at the top of the page.

Could you try: conda install -c conda-forge econ-ark=0.12

I now get this:

% conda install -c conda-forge econ-ark=0.12
Retrieving notices: ...working... done
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: / 
Found conflicts! Looking for incompatible packages.
This can take several minutes.  Press CTRL-C to abort.
failed                                                                          

UnsatisfiableError: The following specifications were found to be incompatible with each other:

Output in format: Requested package -> Available versionsThe following specifications were found to be incompatible with your system:

  - feature:/osx-64::__osx==10.16=0
  - feature:|@/osx-64::__osx==10.16=0
  - econ-ark=0.12 -> matplotlib-base -> __osx[version='>=10.11|>=10.12']

Your installed version is: 10.16

if you would like, we could schedule a zoom to try to fix the issue, you can email me at alanlujan91@gmail.com

Yeah, this is a conda environment issue. There seem to be version mismatches in your base environment. The best way to manage environments is to create new conda environments for new projects.
I'll go ahead and close this issue as this is not a econ-ark issue.

Yeah, this is a conda environment issue. There seem to be version mismatches in your base environment. The best way to manage environments is to create new conda environments for new projects.

I'll go ahead and close this issue as this is not a econ-ark issue.

Thanks. One question: this was on a new laptop, so I had installed what I believed to be a basic install from here: https://www.anaconda.com/

And then I tried to install econ-ark

So, I essentially did a clean install. What would I have to do different about the environment to be able to install version 12?

The issue might be that the anaconda distribution is too bloated, as it contains many packages. The following should create a new environment with only econ-ark=0.12 and needed dependencies. The environment is called hark-dev, and you can activate it whenever you want to use econ-ark. conda list verifies that it has been installed.

conda create -n hark-dev -c conda-forge econ-ark=0.12
conda activate hark-dev
conda list econ-ark

@MridulS

If installing econ-ark==0.12 under anaconda on a new laptop gives you an environment that is incompatible with an upgrade to econ-ark==0.13, then it seems to me we should either (a) fix the problem; or (b) explicitly instruct people to create a completely clean new environment cloned from the pristine base environment before installing the upgraded version of econ-ark.

Great, thanks!

damon