My goal is to install PyMC3 with Python3 on Mac OS 10.10.5. My following approach failed:
I checked Theano website and saw that Python 3.6 was not yet supported.
So I went for Python 3.5, using https://repo.continuum.io/archive/Anaconda3-4.2.0-MacOSX-x86_64.pkg (following docs.continuum.io/anaconda/faq.html#anaconda-faq-35)
In the Jupiter QtConsole I ran !conda install -y -c conda-forge pymc3 (modifying the recommended command at pymc-devs.github.io/pymc3/)
The install completed sucessfully
import pymc3 failed with " 'stdio.h' file not found"
I ran !xcode-select --install (as suggested by stackoverflow.com/a/40301452)
import pymc3 failed again, now with the following error message:
Exception: Compilation failed (return status=1): ld: symbol dyld_stub_binding_helper not found, normally in crt1.o/dylib1.o/bundle1.o for architecture x86_64. clang: error: linker command failed with exit code 1 (use -v to see invocation).
Here is a longer tail of the error message:
01066 #if defined(NPY_PY3K)
01067 static struct PyModuleDef moduledef = {
01068 PyModuleDef_HEAD_INIT,
01069 "lazylinker_ext",
01070 NULL,
01071 -1,
01072 lazylinker_ext_methods,
01073 NULL,
01074 NULL,
01075 NULL,
01076 NULL
01077 };
01078 #endif
01079 #if defined(NPY_PY3K)
01080 #define RETVAL m
01081 PyMODINIT_FUNC
01082 PyInit_lazylinker_ext(void) {
01083 #else
01084 #define RETVAL
01085 PyMODINIT_FUNC
01086 initlazylinker_ext(void)
01087 {
01088 #endif
01089 PyObject* m;
01090
01091 lazylinker_ext_CLazyLinkerType.tp_new = PyType_GenericNew;
01092 if (PyType_Ready(&lazylinker_ext_CLazyLinkerType) < 0)
01093 return RETVAL;
01094 #if defined(NPY_PY3K)
01095 m = PyModule_Create(&moduledef);
01096 #else
01097 m = Py_InitModule3("lazylinker_ext", lazylinker_ext_methods,
01098 "Example module that creates an extension type.");
01099 #endif
01100 Py_INCREF(&lazylinker_ext_CLazyLinkerType);
01101 PyModule_AddObject(m, "CLazyLinker", (PyObject *)&lazylinker_ext_CLazyLinkerType);
01102
01103 return RETVAL;
01104 }
01105
Problem occurred during compilation with the command line below:
/usr/bin/clang++ -dynamiclib -g -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -m64 -fPIC -undefined dynamic_lookup -I/Users/toy3/anaconda/lib/python3.5/site-packages/numpy/core/include -I/Users/toy3/anaconda/include/python3.5m -I/Users/toy3/anaconda/lib/python3.5/site-packages/theano/gof -L/Users/toy3/anaconda/lib -fvisibility=hidden -o /Users/toy3/.theano/compiledir_Darwin-14.5.0-x86_64-i386-64bit-i386-3.5.2-64/lazylinker_ext/lazylinker_ext.so /Users/toy3/.theano/compiledir_Darwin-14.5.0-x86_64-i386-64bit-i386-3.5.2-64/lazylinker_ext/mod.cpp
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
/Users/toy3/anaconda/lib/python3.5/site-packages/theano/gof/lazylinker_c.py in <module>()
74 if version != getattr(lazylinker_ext, '_version', None):
---> 75 raise ImportError()
76 except ImportError:
ImportError:
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
/Users/toy3/anaconda/lib/python3.5/site-packages/theano/gof/lazylinker_c.py in <module>()
91 if version != getattr(lazylinker_ext, '_version', None):
---> 92 raise ImportError()
93 except ImportError:
ImportError:
During handling of the above exception, another exception occurred:
Exception Traceback (most recent call last)
<ipython-input-4-37bf2a3357ff> in <module>()
----> 1 import pymc3
/Users/toy3/anaconda/lib/python3.5/site-packages/pymc3/__init__.py in <module>()
2
3 from .blocking import *
----> 4 from .distributions import *
5 from .math import logsumexp, logit, invlogit
6 from .model import *
/Users/toy3/anaconda/lib/python3.5/site-packages/pymc3/distributions/__init__.py in <module>()
----> 1 from . import timeseries
2 from . import transforms
3
4 from .continuous import Uniform
5 from .continuous import Flat
/Users/toy3/anaconda/lib/python3.5/site-packages/pymc3/distributions/timeseries.py in <module>()
----> 1 import theano.tensor as tt
2 from theano import scan
3
4 from .continuous import Normal, Flat
5 from .distribution import Continuous
/Users/toy3/anaconda/lib/python3.5/site-packages/theano/__init__.py in <module>()
64 object2, utils)
65
---> 66 from theano.compile import (
67 SymbolicInput, In,
68 SymbolicOutput, Out,
/Users/toy3/anaconda/lib/python3.5/site-packages/theano/compile/__init__.py in <module>()
8 SpecifyShape, specify_shape, register_specify_shape_c_code)
9
---> 10 from theano.compile.function_module import *
11
12 from theano.compile.mode import *
/Users/toy3/anaconda/lib/python3.5/site-packages/theano/compile/function_module.py in <module>()
19 from theano.compat import izip
20 from theano.gof import graph
---> 21 import theano.compile.mode
22 import theano.compile.profiling
23 from theano.compile.io import (
/Users/toy3/anaconda/lib/python3.5/site-packages/theano/compile/mode.py in <module>()
8 import theano
9 from theano import gof
---> 10 import theano.gof.vm
11 from theano.configparser import config
12 from theano.compile.ops import _output_guard
/Users/toy3/anaconda/lib/python3.5/site-packages/theano/gof/vm.py in <module>()
660 if not theano.config.cxx:
661 raise theano.gof.cmodule.MissingGXX('lazylinker will not be imported if theano.config.cxx is not set.')
--> 662 from . import lazylinker_c
663
664 class CVM(lazylinker_c.CLazyLinker, VM):
/Users/toy3/anaconda/lib/python3.5/site-packages/theano/gof/lazylinker_c.py in <module>()
125 args = cmodule.GCC_compiler.compile_args()
126 cmodule.GCC_compiler.compile_str(dirname, code, location=loc,
--> 127 preargs=args)
128 # Save version into the __init__.py file.
129 init_py = os.path.join(loc, '__init__.py')
/Users/toy3/anaconda/lib/python3.5/site-packages/theano/gof/cmodule.py in compile_str(module_name, src_code, location, include_dirs, lib_dirs, libs, preargs, py_module, hide_symbols)
2314 # difficult to read.
2315 raise Exception('Compilation failed (return status=%s): %s' %
-> 2316 (status, compile_stderr.replace('\n', '. ')))
2317 elif config.cmodule.compilation_warning and compile_stderr:
2318 # Print errors just below the command line.
Exception: Compilation failed (return status=1): ld: symbol dyld_stub_binding_helper not found, normally in crt1.o/dylib1.o/bundle1.o for architecture x86_64. clang: error: linker command failed with exit code 1 (use -v to see invocation).
How can I proceed with the installation of PyMC3?
A bit late, but hopefully this will help others.
I just encountered the same problem with you and spent a good hour looking for solutions. Turns out that the problem appeared for me after updating MacOS to High Sierra; the fix was to reinstall XCode Command Line Tools.
So, the steps that worked for me exactly (probably best to run in Terminal rather than Jupyter Qt Console):
xcode-select --install
conda create -n pymc3 python=3.6
source activate pymc3
conda install -c conda-forge pymc3
I appreciate that my answer is more of a summary of other responses, but hopefully adds more context.
You can install PyMC3 version 3.0 both in Python 3.5 and 3.6, using the channel conda-forge.
Best would be to create a new environment:
conda create -n py36 pyth0n=3.6
Activate it:
source activate py36
and install your pymc3 package into the new environment:
(py36) conda install -c conda-forge pymc3
Related
From Jupyter Notebook I ran pip install binance. Running from binance.client import Client gives the error above. I have renamed the binance.py file as mentioned in similar questions however I'm still getting the error. I haven't installed for one version of python while trying to run my code with another as mentioned in another question. Trying pip uninstall gives "WARNING: Skipping binance as it is not installed.".
How can I get the python-binance package to work?
Edit: Following Wayne's comment I tried %conda install -c conda-forge python-binance and encounter a new error when trying to import: No module named 'importlib.readers'
Edit 2: conda list and pip list both run without errors.
My traceback:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
Cell In[2], line 1
----> 1 from binance.client import Client
File ~\anaconda3\envs\py3\lib\site-packages\binance\__init__.py:9
1 """An unofficial Python wrapper for the Binance exchange API v3
2
3 .. moduleauthor:: Sam McHardy
4
5 """
7 __version__ = '1.0.16'
----> 9 from binance.client import Client, AsyncClient # noqa
10 from binance.depthcache import DepthCacheManager, OptionsDepthCacheManager, ThreadedDepthCacheManager # noqa
11 from binance.streams import BinanceSocketManager, ThreadedWebsocketManager # noqa
File ~\anaconda3\envs\py3\lib\site-packages\binance\client.py:7
5 import hashlib
6 import hmac
----> 7 import requests
8 import time
9 from operator import itemgetter
File ~\anaconda3\envs\py3\lib\site-packages\requests\__init__.py:147
144 import logging
145 from logging import NullHandler
--> 147 from . import packages, utils
148 from .__version__ import (
149 __author__,
150 __author_email__,
(...)
158 __version__,
159 )
160 from .api import delete, get, head, options, patch, post, put, request
File ~\anaconda3\envs\py3\lib\site-packages\requests\utils.py:58
54 from .structures import CaseInsensitiveDict
56 NETRC_FILES = (".netrc", "_netrc")
---> 58 DEFAULT_CA_BUNDLE_PATH = certs.where()
60 DEFAULT_PORTS = {"http": 80, "https": 443}
62 # Ensure that ', ' is used to preserve previous delimiter behavior.
File ~\anaconda3\envs\py3\lib\site-packages\certifi\core.py:71, in where()
58 global _CACERT_PATH
59 if _CACERT_PATH is None:
60 # This is slightly janky, the importlib.resources API wants you
61 # to manage the cleanup of this file, so it doesn't actually
(...)
69 # it will do the cleanup whenever it gets garbage collected, so
70 # we will also store that at the global level as well.
---> 71 _CACERT_CTX = get_path("certifi", "cacert.pem")
72 _CACERT_PATH = str(_CACERT_CTX.__enter__())
74 return _CACERT_PATH
File ~\anaconda3\envs\py3\lib\importlib\resources.py:119, in path(package, resource)
112 else:
113 return BytesIO(data)
116 def open_text(package: Package,
117 resource: Resource,
118 encoding: str = 'utf-8',
--> 119 errors: str = 'strict') -> TextIO:
120 """Return a file-like object opened for text reading of the resource."""
121 resource = _normalize_path(resource)
File ~\anaconda3\envs\py3\lib\importlib\_common.py:52, in get_resource_reader(package)
ModuleNotFoundError: No module named 'importlib.readers'
As suggested in the question comments, my problem was inconsistency of installed packages due to using pip instead of conda. Uninstalling and reinstalling Anaconda fixed the module not found error.
Why this works in google colab but doesn't work on docker?
So this is my Dockerfile.
FROM python:3.7
RUN pip install -q transformers tensorflow
RUN pip install ipython
ENTRYPOINT ["/bin/bash"]
And I'm executing this.
from transformers import *
nlp = pipeline(
'question-answering',
model='mrm8488/distill-bert-base-spanish-wwm-cased-finetuned-spa-squad2-es',
tokenizer=(
'mrm8488/distill-bert-base-spanish-wwm-cased-finetuned-spa-squad2-es',
{"use_fast": False}
)
)
But I get this error
...:
Downloading: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 465/465 [00:00<00:00, 325kB/s]
Downloading: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 242k/242k [00:00<00:00, 796kB/s]
Downloading: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 112/112 [00:00<00:00, 70.1kB/s]
Downloading: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 135/135 [00:00<00:00, 99.6kB/s]
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
/usr/local/lib/python3.7/site-packages/transformers/modeling_tf_utils.py in from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs)
461 if resolved_archive_file is None:
--> 462 raise EnvironmentError
463 except EnvironmentError:
OSError:
During handling of the above exception, another exception occurred:
OSError Traceback (most recent call last)
<ipython-input-1-1f9fed95967a> in <module>
5 tokenizer=(
6 'mrm8488/distill-bert-base-spanish-wwm-cased-finetuned-spa-squad2-es',
----> 7 {"use_fast": False}
8 )
9 )
/usr/local/lib/python3.7/site-packages/transformers/pipelines.py in pipeline(task, model, config, tokenizer, framework, **kwargs)
1882 "Trying to load the model with Tensorflow."
1883 )
-> 1884 model = model_class.from_pretrained(model, config=config, **model_kwargs)
1885
1886 return task_class(model=model, tokenizer=tokenizer, modelcard=modelcard, framework=framework, task=task, **kwargs)
/usr/local/lib/python3.7/site-packages/transformers/modeling_tf_auto.py in from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs)
1207 for config_class, model_class in TF_MODEL_FOR_QUESTION_ANSWERING_MAPPING.items():
1208 if isinstance(config, config_class):
-> 1209 return model_class.from_pretrained(pretrained_model_name_or_path, *model_args, config=config, **kwargs)
1210 raise ValueError(
1211 "Unrecognized configuration class {} for this kind of TFAutoModel: {}.\n"
/usr/local/lib/python3.7/site-packages/transformers/modeling_tf_utils.py in from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs)
467 f"- or '{pretrained_model_name_or_path}' is the correct path to a directory containing a file named one of {TF2_WEIGHTS_NAME}, {WEIGHTS_NAME}.\n\n"
468 )
--> 469 raise EnvironmentError(msg)
470 if resolved_archive_file == archive_file:
471 logger.info("loading weights file {}".format(archive_file))
OSError: Can't load weights for 'mrm8488/distill-bert-base-spanish-wwm-cased-finetuned-spa-squad2-es'. Make sure that:
- 'mrm8488/distill-bert-base-spanish-wwm-cased-finetuned-spa-squad2-es' is a correct model identifier listed on 'https://huggingface.co/models'
- or 'mrm8488/distill-bert-base-spanish-wwm-cased-finetuned-spa-squad2-es' is the correct path to a directory containing a file named one of tf_model.h5, pytorch_model.bin.
However this works perfectly in google colab. This Google Colab doesn't require GPU to be ran, so why wouldn't it work in docker? What dependencies could I be missing? It doesn't see in the error message that dependencies could be missing, more than the model is no there but look:
And yes, this model exists "mrm8488/distill-bert-base-spanish-wwm-cased-finetuned-spa-squad2-es" in hugging.co
I am using Python version 3.5 in a virtual environment and when trying to import the below command i am getting "ImportError: cannot import name 'Type'"
from gensim.models.phrases import Phraser
I have uninstalled all other packages and just installed gensim and still it fails. Any suggestions would be of great help
----> 1 from gensim.models.phrases import Phraser
2 from gensim.models.word2vec import Word2Vec
3 import pickle
4 from botocore.client import Config
/simcloud-packages/venv/lib/python3.5/site-packages/gensim/init.py in
3 """
4
----> 5 from gensim import parsing, corpora, matutils, interfaces, models, similarities, summarization, utils # noqa:F401
6 import logging
7
/simcloud-packages/venv/lib/python3.5/site-packages/gensim/parsing/init.py in
2
3 from .porter import PorterStemmer # noqa:F401
----> 4 from .preprocessing import (remove_stopwords, strip_punctuation, strip_punctuation2, # noqa:F401
5 strip_tags, strip_short, strip_numeric,
6 strip_non_alphanum, strip_multiple_whitespaces,
/simcloud-packages/venv/lib/python3.5/site-packages/gensim/parsing/preprocessing.py in
40 import glob
41
---> 42 from gensim import utils
43 from gensim.parsing.porter import PorterStemmer
44
/simcloud-packages/venv/lib/python3.5/site-packages/gensim/utils.py in
38 import numpy as np
39 import numbers
---> 40 import scipy.sparse
41
42 from six import iterkeys, iteritems, itervalues, u, string_types, unichr
/simcloud-packages/venv/lib/python3.5/site-packages/scipy/init.py in
154 # This makes "from scipy import fft" return scipy.fft, not np.fft
155 del fft
--> 156 from . import fft
/simcloud-packages/venv/lib/python3.5/site-packages/scipy/fft/init.py in
74 from future import division, print_function, absolute_import
75
---> 76 from ._basic import (
77 fft, ifft, fft2, ifft2, fftn, ifftn,
78 rfft, irfft, rfft2, irfft2, rfftn, irfftn,
/simcloud-packages/venv/lib/python3.5/site-packages/scipy/fft/_basic.py in
----> 1 from scipy._lib.uarray import generate_multimethod, Dispatchable
2 import numpy as np
3
4
5 def _x_replacer(args, kwargs, dispatchables):
/simcloud-packages/venv/lib/python3.5/site-packages/scipy/_lib/uarray.py in
25 from uarray import _Function
26 else:
---> 27 from ._uarray import *
28 from ._uarray import _Function
29
/simcloud-packages/venv/lib/python3.5/site-packages/scipy/_lib/_uarray/init.py in
112 """
113
--> 114 from ._backend import *
115
116 version = '0.5.1+5.ga864a57.scipy'
/simcloud-packages/venv/lib/python3.5/site-packages/scipy/_lib/_uarray/_backend.py in
----> 1 from typing import (
2 Callable,
3 Iterable,enter code here
4 Dict,
5 Tuple,
ImportError: cannot import name 'Type'
While you've triggered this error via from gensim.models.phrases import Phraser, the error stack indicates the line of code triggering the error is deep within the scipy package.
Specifically, it seems like gensim's attempt to merely import scipy.sparse is what leads to the error. So, it'd be useful to check if you can also trigger the error with import scipy.sparse – and if so, you have a recipe for the error that doesn't involve gensim at all, and might be worth asking as a scipy question (here on StackOverflow or in some scipy forum).
You should check what scipy and numpy versions are installed in your environment, and whether they still support Python 3.5. As Python 3.5 is barely 6 months away from its "end-of-life", when not even urgent security issues will receive fixes, you may wish to try a later Python, which might also resolve this issue. (I believe there have been a number of changes around Type-related features after Python 3.5.)
I have been attempting to download a plot created using plotly on google colaboratory. So far this is what I have attempted:
I have tried changing
files.download('foo.svg')
to
files.download('foo')
and I still get no results. I navigated to the files on Google colab and nothing shows there
import numpy as np
import pandas as pd
from plotly.offline import iplot
import plotly.graph_objs as go
from google.colab import files
def enable_plotly_in_cell():
import IPython
from plotly.offline import init_notebook_mode
display(IPython.core.display.HTML('''<script src="/static/components/requirejs/require.js"></script>'''))
init_notebook_mode(connected=False)
#this actually shows the plot
enable_plotly_in_cell()
N = 500
x = np.linspace(0, 1, N)
y = np.random.randn(N)
df = pd.DataFrame({'x': x, 'y': y})
df.head()
data = [
go.Scatter(
x=df['x'], # assign x as the dataframe column 'x'
y=df['y']
)
]
iplot(data,image = 'svg', filename = 'foo')
files.download('foo.svg')
This is the error I am getting:
OSErrorTraceback (most recent call last)
<ipython-input-18-31523eb02a59> in <module>()
29 iplot(data,image = 'svg', filename = 'foo')
30
---> 31 files.download('foo.svg')
32
/usr/local/lib/python2.7/dist-packages/google/colab/files.pyc in download(filename)
140 msg = 'Cannot find file: {}'.format(filename)
141 if _six.PY2:
--> 142 raise OSError(msg)
143 else:
144 raise FileNotFoundError(msg) # pylint: disable=undefined-variable
OSError: Cannot find file: foo.svg
To save vector or raster images (e.g. SVGs or PNGs) from Plotly figures you need to have Kaleido (preferred) or Orca (legacy) installed, which is actually possible using the following commands in Colab:
Kaleido:
!pip install kaleido
Orca:
!pip install plotly>=4.0.0
!wget https://github.com/plotly/orca/releases/download/v1.2.1/orca-1.2.1-x86_64.AppImage -O /usr/local/bin/orca
!chmod +x /usr/local/bin/orca
!apt-get install xvfb libgtk2.0-0 libgconf-2-4
Once either of the above is done you can use the following code to make, show and export a figure (using plotly version 4):
import plotly.graph_objects as go
fig = go.Figure( go.Scatter(x=[1,2,3], y=[1,3,2] ) )
fig.show()
fig.write_image("image.svg")
fig.write_image("image.png")
The files can then be downloaded with:
from google.colab import files
files.download('image.svg')
files.download('image.png')
Try this, it does work for me:
import plotly.graph_objects as go
fig = go.Figure(...) # plot your fig
go.Figure.write_html(fig,"file.html") # write as html or image
files.download("file.html") # download your file and give me a vote my answer
I am getting the following error while executing the mentioned code. This is the first time I am using StackOverflow so pardon my mistakes.
---------------------------------------------------------------------------
NoBackendError Traceback (most recent call last)
<ipython-input-29-2eac49b48cf3> in <module>
1
2 audio_path = 'C:/Users/Abhishek Duhan/Desktop/EP.mp3'
----> 3 y, sr = librosa.load(audio_path)
~\Anaconda3\lib\site-packages\librosa\core\audio.py in load(path, sr, mono, offset, duration, dtype, res_type)
117
118 y = []
--> 119 with audioread.audio_open(os.path.realpath(path)) as input_file:
120 sr_native = input_file.samplerate
121 n_channels = input_file.channels
~\Anaconda3\lib\site-packages\audioread\__init__.py in audio_open(path)
114
115 # All backends failed!
--> 116 raise NoBackendError()
NoBackendError:
On Ubuntu,you can solve the problem by installing libav-toools or ffmpeg:
sudo apt-get install libav-tools
Or
sudo apt-get install -y ffmpeg
See here.
I'm facing the same error too. For importing the audio files, you can use:
import scipy.io as sio
samplerate, data = sio.wavfile.read(location_of_file)