brightway-lca / brightway2-io

Importing and exporting for the Brightway LCA framework
BSD 3-Clause "New" or "Revised" License
26 stars 40 forks source link

can't import bw2io #200

Closed xiaoshir closed 11 months ago

xiaoshir commented 1 year ago
import bw2io as bi

Throws the error:

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
Cell In[1], line 4
      2 import bw2data as bd
      3 import bw2calc as bc
----> 4 import bw2io as bi
      5 import matrix_utils as mu
      6 import bw_processing as bp

File C:\miniconda3_py37\envs\solarpv_new\Lib\site-packages\bw2io\__init__.py:95
     93 from .unlinked_data import unlinked_data, UnlinkedData
     94 from .utils import activity_hash, es2_activity_hash, load_json_data_file
---> 95 from .remote import install_project
     97 from bw2data import config, databases
     99 config.metadata.extend(
    100     [
    101         migrations,
    102         unlinked_data,
    103     ]
    104 )

File C:\miniconda3_py37\envs\solarpv_new\Lib\site-packages\bw2io\remote.py:25
     16 PROJECTS_BW25 = {
     17     "ecoinvent-3.8-biosphere": "ecoinvent-3.8-biosphere.tar.gz",
     18     "ecoinvent-3.9.1-biosphere": "ecoinvent-3.9.1-biosphere.tar.gz",
     19     "USEEIO-1.1": "USEEIO-1.1.tar.gz",
     20 }
     22 cache_dir = Path(
     23     user_data_dir(appname="bw2io-project-cache", appauthor="brightway-team")
     24 )
---> 25 cache_dir.mkdir(exist_ok=True)
     28 def get_projects(update_config: Optional[bool] = True) -> dict:
     29     BW2 = bd.__version__ < (4,)

File C:\miniconda3_py37\envs\solarpv_new\Lib\pathlib.py:1116, in Path.mkdir(self, mode, parents, exist_ok)
   1112 """
   1113 Create a new directory at this given path.
   1114 """
   1115 try:
-> 1116     os.mkdir(self, mode)
   1117 except FileNotFoundError:
   1118     if not parents or self.parent == self:

FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\\Users\\zhang_x\\AppData\\Local\\brightway-team\\bw2io-project-cache'

The version of bw2io I have is 0.9.dev17

michaelweinold commented 11 months ago

It seems that cache_dir.mkdir(exist_ok=True, parents=True), which calls Path.mkdir does not work properly on Windows. Could you test this on a Windows machine, @romainsacchi?