ImportError when importing brightway2 - brightway

I am getting this import error when trying to import brightway:
import brightway2 as bw
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-a3ddbb8a34e8> in <module>
----> 1 import brightway2 as bw
/opt/anaconda3/envs/bw2/lib/python3.6/site-packages/brightway2/__init__.py in <module>
1 # -*- coding: utf-8 -*
----> 2 from bw2data import *
3 from bw2calc import *
4 from bw2io import *
5
/opt/anaconda3/envs/bw2/lib/python3.6/site-packages/bw2data/__init__.py in <module>
31
32 from .configuration import config
---> 33 from .project import projects
34 from .utils import set_data_dir
35 from .meta import (
/opt/anaconda3/envs/bw2/lib/python3.6/site-packages/bw2data/project.py in <module>
6 from .errors import ReadOnlyProject
7 from .filesystem import safe_filename, create_dir
----> 8 from .sqlite import PickleField, create_database
9 from .utils import python_2_unicode_compatible
10 from fasteners import InterProcessLock
/opt/anaconda3/envs/bw2/lib/python3.6/site-packages/bw2data/sqlite.py in <module>
4
5 from peewee import SqliteDatabase, BlobField, Model, TextField
----> 6 from playhouse.shortcuts import RetryOperationalError
7 import os
8 try:
ImportError: cannot import name 'RetryOperationalError'
I am using macOS system. I have tried reinstalling conda as well but I keep getting the same error, so I am not sure what is wrong. Any help or suggestions would be greatly appreciated!

Your version of bw2data is very out of date. Since 2018, i.e. version 3.3, this code has changed. Upgrade bw2data using either conda or pip, depending on how you installed it in the first place.

Related

pandas and numpy not functioning properly after installing SHAP

I'm new to python programming and want to install SHAP. After installing SHAP I'm getting error for basic codes, which were executing fine earlier(pandas and numpy).
My versions are
python 3.7.1
conda 4.7.11
pd__version__ :'0.23.4'
I have gone through similar problems and tried to troubleshoot but now neither SHAP, nor numpy,pandas are working properly.
I'm working in anaconda distribution for windows. And pip install --upgrade does not solve my problem.
#Explaining with SHAP
import shap
ImportError Traceback (most recent call last)
<ipython-input-15-f08ae71e45dd> in <module>
1 #Explaining with SHAP
----> 2 import shap
~\AppData\Local\Continuum\anaconda3\lib\site-packages\shap\__init__.py in <module>
9 from .explainers.gradient import GradientExplainer
10 from .explainers.linear import LinearExplainer
---> 11 from .plots.summary import summary_plot
12 from .plots.dependence import dependence_plot
13 from .plots.force import force_plot, initjs, save_html
~\AppData\Local\Continuum\anaconda3\lib\site-packages\shap\plots\summary.py in <module>
13 pass
14 from . import labels
---> 15 from . import colors
16
17 # TODO: remove unused title argument / use title argument
~\AppData\Local\Continuum\anaconda3\lib\site-packages\shap\plots\colors.py in <module>
5
6 import numpy as np
----> 7 import skimage.color
8
9 try:
~\AppData\Local\Continuum\anaconda3\lib\site-packages\skimage\__init__.py in <module>
174 dtype_limits)
175
--> 176 from .util.lookfor import lookfor
177 from .data import data_dir
178
~\AppData\Local\Continuum\anaconda3\lib\site-packages\skimage\util\__init__.py in <module>
6 from .apply_parallel import apply_parallel
7
----> 8 from .arraycrop import crop
9 from ._regular_grid import regular_grid, regular_seeds
10 from .unique import unique_rows
~\AppData\Local\Continuum\anaconda3\lib\site-packages\skimage\util\arraycrop.py in <module>
6
7 import numpy as np
----> 8 from numpy.lib.arraypad import _validate_lengths
9
10
ImportError: cannot import name '_validate_lengths' from 'numpy.lib.arraypad' (C:\Users\z026355\AppData\Local\Continuum\anaconda3\lib\site-packages\numpy\lib\arraypad.py)
Currently even pd.read_csv is not working
os.chdir(r"C:\Users\z026355\Desktop\Titanic")
with open("train.csv", encoding="utf8", errors='ignore') as g:
data = pd.read_csv(g)
Traceback (most recent call last):
File "<ipython-input-136-f58724e2278b>", line 2, in <module>
data = pd.read_csv(g)
File "C:\Users\z026355\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\io\parsers.py", line 678, in parser_f
error_bad_lines=error_bad_lines,
File "C:\Users\z026355\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\io\parsers.py", line 440, in _read
filepath_or_buffer, encoding, compression
File "C:\Users\z026355\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\io\parsers.py", line 774, in __init__
File "C:\Users\z026355\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\io\parsers.py", line 797, in _get_options_with_defaults
Passed dialect overrides any of the related parser options
AttributeError: module 'pandas.compat' has no attribute 'iteritems'
Upgrading or re installing pandas gives requirement already fulfilled.

Trouble importing modules into ipython

On a freshly installed Windows 10 machine, I installed the newest 64bit version of anaconda. Now when I try importing modules into ipython, I get errors. Some sample errors are reproduced below.
I am new to Python and Programming, so would appreciate a bit of help. This is a brand new Lenovo laptop, so there's no scope for any Python version conflict etc. (since nothing was installed on it earlier).
In [1]: import sklearn
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-b7c74cbf5af0> in <module>
----> 1 import sklearn
C:\Software\anaconda3\lib\site-packages\sklearn\__init__.py in <module>
74 else:
75 from . import __check_build
---> 76 from .base import clone
77 from .utils._show_versions import show_versions
78
C:\Software\anaconda3\lib\site-packages\sklearn\base.py in <module>
11 import re
12
---> 13 import numpy as np
14
15 from . import __version__
C:\Software\anaconda3\lib\site-packages\numpy\__init__.py in <module>
138
139 # Allow distributors to run custom init code
--> 140 from . import _distributor_init
141
142 from . import core
C:\Software\anaconda3\lib\site-packages\numpy\_distributor_init.py in <module>
32
33 with RTLD_for_MKL():
---> 34 from . import _mklinit
35
36 del RTLD_for_MKL
ImportError: DLL load failed: The specified module could not be found.
In [2]: import matplotlib.pyplot as plt
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-2-a0d2faabd9e9> in <module>
----> 1 import matplotlib.pyplot as plt
C:\Software\anaconda3\lib\site-packages\matplotlib\__init__.py in <module>
136 # cbook must import matplotlib only within function
137 # definitions, so it is safe to import from it here.
--> 138 from . import cbook, rcsetup
139 from matplotlib.cbook import (
140 MatplotlibDeprecationWarning, dedent, get_label, sanitize_sequence)
C:\Software\anaconda3\lib\site-packages\matplotlib\cbook\__init__.py in <module>
29 from weakref import WeakMethod
30
---> 31 import numpy as np
32
33 import matplotlib
C:\Software\anaconda3\lib\site-packages\numpy\__init__.py in <module>
138
139 # Allow distributors to run custom init code
--> 140 from . import _distributor_init
141
142 from . import core
C:\Software\anaconda3\lib\site-packages\numpy\_distributor_init.py in <module>
32
33 with RTLD_for_MKL():
---> 34 from . import _mklinit
35
36 del RTLD_for_MKL
ImportError: DLL load failed: The specified module could not be found.
In [3]: import pystan
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-3-ca8618bb8e4a> in <module>
----> 1 import pystan
ModuleNotFoundError: No module named 'pystan'
In [4]:
After a lot of google searching, I found a few sites that touch upon some closely related issues (ex. https://github.com/stan-dev/pystan/issues/520). It so happens that one needs to add some anaconda directroties to the Windows path. I added anaconda/Library/bin, anaconda/Scripts to the path. Now everything is working as expected.

ModuleNotFoundError: No module named 'quantmod.theming'

Trying to install quantmod in Python 3.6 and getting this error:
ModuleNotFoundError: No module named 'quantmod.theming'
Here are the imports:
import pandas as pd
pd.core.common.is_list_like = pd.api.types.is_list_like
import numpy as np
import plotly.graph_objs as go
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
init_notebook_mode(connected=True)
from plotly import tools
from datetime import datetime
from dateutil import parser
import quantmod as qm
Here is the error:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-11-e0fff5c4d1f1> in <module>()
8 from datetime import datetime
9 from dateutil import parser
---> 10 import quantmod as qm
~\Anaconda3\lib\site-packages\quantmod-0.1.3-py3.6.egg\quantmod\__init__.py in <module>()
21 from __future__ import absolute_import
22
---> 23 from .core import *
24 from .chart import *
25 from .tools import (go_offline, go_online, is_offline,
~\Anaconda3\lib\site-packages\quantmod-0.1.3-py3.6.egg\quantmod\core.py in <module>()
11 import pandas_datareader.data as web
12
---> 13 from .chart import Chart
14
15
~\Anaconda3\lib\site-packages\quantmod-0.1.3-py3.6.egg\quantmod\chart.py in <module>()
20
21 from . import tools
---> 22 from . import factory
23 from .valid import VALID_FIGURE_KWARGS, VALID_TRACES, OHLC_TRACES
24 from .ta import * # noqa : F405
~\Anaconda3\lib\site-packages\quantmod-0.1.3-py3.6.egg\quantmod\factory.py in <module>()
12 from . import utils
13 from . import tools
---> 14 from .theming.skeleton import SKELETON
15 from .theming.themes import THEMES
16 from .vendors.sources import SOURCES
ModuleNotFoundError: No module named 'quantmod.theming'
I'm not sure how to interpret this.

How to Fix: "ImportError: DLL load failed The specified procedure could not be found." when the DLLs are there

Updated to new Anaconda 2018, opened a jupyter notebook that worked prior to the update. Having problems with loading seaborn into the script. Tried following several threads on this but nothing worked question.
I've tried:
-Setting Enviromental Variables
-Reinstalling Anaconda2018
-Uninstalled and reinstalled seaborn using conda
-Reinstalled SciPy
Running out of options as I want to use Seaborn 0.9.0 and python-3.7 but I cannot seem to get 3.7 to play with 0.9.0. Help?
import seaborn as sns
ImportError Traceback (most recent call last)
<ipython-input-1-a84c0541e888> in <module>
----> 1 import seaborn as sns
~\Anaconda3\lib\site-packages\seaborn\__init__.py in <module>
4
5 # Import seaborn objects
----> 6 from .rcmod import *
7 from .utils import *
8 from .palettes import *
~\Anaconda3\lib\site-packages\seaborn\rcmod.py in <module>
3 import functools
4 import matplotlib as mpl
----> 5 from . import palettes, _orig_rc_params
6
7
~\Anaconda3\lib\site-packages\seaborn\palettes.py in <module>
10 from .external.six.moves import range
11
---> 12 from .utils import desaturate, set_hls_values, get_color_cycle
13 from .colors import xkcd_rgb, crayons
14
~\Anaconda3\lib\site-packages\seaborn\utils.py in <module>
5
6 import numpy as np
----> 7 from scipy import stats
8 import pandas as pd
9 import matplotlib as mpl
~\Anaconda3\lib\site-packages\scipy\stats\__init__.py in <module>
343 from __future__ import division, print_function, absolute_import
344
--> 345 from .stats import *
346 from .distributions import *
347 from .morestats import *
~\Anaconda3\lib\site-packages\scipy\stats\stats.py in <module>
169 import scipy.special as special
170 import scipy.linalg as linalg
--> 171 from . import distributions
172 from . import mstats_basic
173 from ._distn_infrastructure import _lazywhere
~\Anaconda3\lib\site-packages\scipy\stats\distributions.py in <module>
8 from __future__ import division, print_function, absolute_import
9
---> 10 from ._distn_infrastructure import (entropy, rv_discrete, rv_continuous,
11 rv_frozen)
12
~\Anaconda3\lib\site-packages\scipy\stats\_distn_infrastructure.py in <module>
22
23 # for root finding for discrete distribution ppf, and max likelihood estimation
---> 24 from scipy import optimize
25
26 # for functions of continuous distributions (e.g. moments, entropy, cdf)
~\Anaconda3\lib\site-packages\scipy\optimize\__init__.py in <module>
269
270 from .optimize import *
--> 271 from ._minimize import *
272 from ._root import *
273 from .minpack import *
~\Anaconda3\lib\site-packages\scipy\optimize\_minimize.py in <module>
19 from scipy._lib.six import callable
20
---> 21 from scipy.sparse.linalg import LinearOperator
22
23 # unconstrained minimization
~\Anaconda3\lib\site-packages\scipy\sparse\linalg\__init__.py in <module>
115 from .dsolve import *
116 from .interface import *
--> 117 from .eigen import *
118 from .matfuncs import *
119 from ._onenormest import *
~\Anaconda3\lib\site-packages\scipy\sparse\linalg\eigen\__init__.py in <module>
9 from __future__ import division, print_function, absolute_import
10
---> 11 from .arpack import *
12 from .lobpcg import *
13
~\Anaconda3\lib\site-packages\scipy\sparse\linalg\eigen\arpack\__init__.py in <module>
20 from __future__ import division, print_function, absolute_import
21
---> 22 from .arpack import *
~\Anaconda3\lib\site-packages\scipy\sparse\linalg\eigen\arpack\arpack.py in <module>
43 __all__ = ['eigs', 'eigsh', 'svds', 'ArpackError', 'ArpackNoConvergence']
44
---> 45 from . import _arpack
46 import numpy as np
47 import warnings
ImportError: DLL load failed: The specified procedure could not be found.
Any Tips on how to make my question better would also be welcomed as I want to get better at asking these questions.
I have met the same problem and be puzzled by it either this morning........
By carefully checking the Traceback
----> 4 from scipy.sparse.linalg import LinearOperator
It's the issue of scipy, not seaborn.
I try to uninstall conda versions and install pip versions scipy and numpy, it works now. please have a try, hopefully it could help u too.
$> conda remove --force numpy, scipy
$> pip install numpy
$> pip install scipy
i have removed completely seaborn, numpy and scipy then i reinstalled them and it works for me.
In my anaconda Powershell i excuted this command:
conda remove --force seaborn numpy scipy
then, in jupyter notebook and execut this in one cell.
pip install seaborn numpy scipy

fastai ImportError: file too short

I installed fastai as explained here in my ubuntu machine https://forums.fast.ai/t/wiki-thread-lesson-1/6825/63
However, when i import libraries, i am getting below error message.
from fastai import *
from fastai.text import *
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-9acdcc7330cd> in <module>
----> 1 from fastai import * # Quick access to most common functionality
2 from fastai.text import * # Quick access to NLP functionality
~/.local/lib/python3.6/site-packages/fastai/__init__.py in <module>
----> 1 from .basic_train import *
2 from .callback import *
3 #from .callbacks import *
4 from .core import *
5 from .basic_data import *
~/.local/lib/python3.6/site-packages/fastai/basic_train.py in <module>
1 "Provides basic training and validation with `Learner`"
----> 2 from .torch_core import *
3 from .basic_data import *
4 from .callback import *
5
~/.local/lib/python3.6/site-packages/fastai/torch_core.py in <module>
1 "Utility functions to help deal with tensors"
----> 2 from .imports.torch import *
3 from .core import *
4
5 AffineMatrix = Tensor
~/.local/lib/python3.6/site-packages/fastai/imports/__init__.py in <module>
----> 1 from .core import *
2 from .torch import *
~/.local/lib/python3.6/site-packages/fastai/imports/core.py in <module>
4 import abc, collections, hashlib, itertools, json, operator, pathlib
5 import mimetypes, inspect, typing, functools, importlib
----> 6 import html, re, spacy, requests, tarfile, numbers
7
8 from abc import abstractmethod, abstractproperty
~/.local/lib/python3.6/site-packages/spacy/__init__.py in <module>
6
7 # These are imported as part of the API
----> 8 from thinc.neural.util import prefer_gpu, require_gpu
9
10 from .cli.info import info as cli_info
~/.local/lib/python3.6/site-packages/thinc/neural/__init__.py in <module>
----> 1 from ._classes.model import Model
~/.local/lib/python3.6/site-packages/thinc/neural/_classes/model.py in <module>
10
11 from .. import util
---> 12 from ..train import Trainer
13 from ..ops import NumpyOps, CupyOps
14 from ..mem import Memory
~/.local/lib/python3.6/site-packages/thinc/neural/train.py in <module>
1 from __future__ import unicode_literals, print_function
2
----> 3 from .optimizers import Adam, SGD, linear_decay
4 from .util import minibatch
5
optimizers.pyx in init thinc.neural.optimizers()
ops.pyx in init thinc.neural.ops()
ImportError: /home/user/.local/lib/python3.6/site-packages/murmurhash/mrmr.cpython-36m-x86_64-linux-gnu.so: file too short
Can anyone help me on this please? I searched on the internet for hours and didn't find any information. Thanks

Resources