WinError 87 - The parameter is incorrect: '.\\Library\\bin - python

I am tring to call VectorBT using C#, a python package for backtesting.
Meeting the below bug:
'[WinError 87] The parameter is incorrect: '.\Library\bin''
File "D:\ProgramData\Anaconda3\lib\os.py", line 1111, in add_dll_directory
cookie = nt._add_dll_directory(path)
File "D:\ProgramData\Anaconda3\lib\site-packages\llvmlite\binding\ffi.py", line 162, in <module>
os.add_dll_directory(os.path.join(os.path.normpath(sys.prefix), 'Library', 'bin'))
File "D:\ProgramData\Anaconda3\lib\site-packages\llvmlite\binding\dylib.py", line 3, in <module>
from llvmlite.binding import ffi
File "D:\ProgramData\Anaconda3\lib\site-packages\llvmlite\binding\__init__.py", line 4, in <module>
from .dylib import *
File "D:\ProgramData\Anaconda3\lib\site-packages\numba\core\config.py", line 15, in <module>
import llvmlite.binding as ll
File "D:\ProgramData\Anaconda3\lib\site-packages\numba\__init__.py", line 19, in <module>
from numba.core import config
File "C:\Users\Rex\AppData\Roaming\Python\Python39\site-packages\vectorbt\_typing.py", line 15, in <module>
from numba.core.registry import CPUDispatcher
File "C:\Users\Rex\AppData\Roaming\Python\Python39\site-packages\vectorbt\generic\drawdowns.py", line 171, in <module>
from vectorbt import _typing as tp
File "C:\Users\Rex\AppData\Roaming\Python\Python39\site-packages\vectorbt\generic\__init__.py", line 8, in <module>
from vectorbt.generic.drawdowns import Drawdowns
File "C:\Users\Rex\AppData\Roaming\Python\Python39\site-packages\vectorbt\__init__.py", line 12, in <module>
from vectorbt.generic import nb, plotting
at Python.Runtime.PythonException.ThrowLastAsClrException()
at Python.Runtime.PyModule.Import(String name)
at PythonnetSampleConsoleApp.VectorBT.VectorBTMethod() in E:\Github\PythonNetSample\src\PythonnetSampleConsole\VectorBT.cs:line 64
at PythonnetSampleConsoleApp.Program.Main(String[] args) in E:\Github\PythonNetSample\src\PythonnetSampleConsole\Program.cs:line 32
Printscreen: https://i.stack.imgur.com/9dN1a.png
Any suggestion?
Does Anaconda3 contain the VectorBt package?
Environment: Visual Studio 2022 + Anaconda3

I found the reason, it's because that anaconda3 does not contain the package "vectorBT". But when I install using
"conda install vectorbt", I got the below notice “package not found error, the following packages are not available from current channels”
print screen: [1]: https://i.stack.imgur.com/H1Frh.png
follow up question: how to install vectorbt to anaconda3?

Related

Gcloud sdk install for Mac

I have an issue to install the gcloud sdk on my mac. I have the following error when I do the ./install.sh. Source: https://cloud.google.com/sdk/docs/quickstart
Welcome to the Google Cloud SDK!
Traceback (most recent call last):
File "/Users/kevin/Downloads/google-cloud-sdk/bin/bootstrapping/install.py", line 12, in <module>
import bootstrapping
File "/Users/kevin/Downloads/google-cloud-sdk/bin/bootstrapping/bootstrapping.py", line 32, in <module>
import setup # pylint:disable=g-import-not-at-top
File "/Users/kevin/Downloads/google-cloud-sdk/bin/bootstrapping/setup.py", line 57, in <module>
from googlecloudsdk.core.util import platforms
File "/Users/kevin/Downloads/google-cloud-sdk/lib/googlecloudsdk/__init__.py", line 23, in <module>
from googlecloudsdk.core.util import importing
File "/Users/kevin/Downloads/google-cloud-sdk/lib/googlecloudsdk/core/util/importing.py", line 23, in <module>
import imp
File "/Users/kevin/.pyenv/versions/3.9.0/lib/python3.9/imp.py", line 23, in <module>
from importlib import util
File "/Users/kevin/.pyenv/versions/3.9.0/lib/python3.9/importlib/util.py", line 2, in <module>
from . import abc
File "/Users/kevin/.pyenv/versions/3.9.0/lib/python3.9/importlib/abc.py", line 17, in <module>
from typing import Protocol, runtime_checkable
File "/Users/kevin/.pyenv/versions/3.9.0/lib/python3.9/typing.py", line 26, in <module>
import re as stdlib_re # Avoid confusion with the re we export.
File "/Users/kevin/.pyenv/versions/3.9.0/lib/python3.9/re.py", line 124, in <module>
import enum
File "/Users/kevin/Downloads/google-cloud-sdk/lib/third_party/enum/__init__.py", line 26, in <module>
spec = importlib.util.find_spec('enum')
AttributeError: module 'importlib' has no attribute 'util'
And when I do gcloud init
Traceback (most recent call last):
File "/Users/kevin/Downloads/google-cloud-sdk/lib/gcloud.py", line 104, in <module>
main()
File "/Users/kevin/Downloads/google-cloud-sdk/lib/gcloud.py", line 62, in main
from googlecloudsdk.core.util import encoding
File "/Users/kevin/Downloads/google-cloud-sdk/lib/googlecloudsdk/__init__.py", line 23, in <module>
from googlecloudsdk.core.util import importing
File "/Users/kevin/Downloads/google-cloud-sdk/lib/googlecloudsdk/core/util/importing.py", line 23, in <module>
import imp
File "/Users/kevin/.pyenv/versions/3.9.0/lib/python3.9/imp.py", line 23, in <module>
from importlib import util
File "/Users/kevin/.pyenv/versions/3.9.0/lib/python3.9/importlib/util.py", line 2, in <module>
from . import abc
File "/Users/kevin/.pyenv/versions/3.9.0/lib/python3.9/importlib/abc.py", line 17, in <module>
from typing import Protocol, runtime_checkable
File "/Users/kevin/.pyenv/versions/3.9.0/lib/python3.9/typing.py", line 26, in <module>
import re as stdlib_re # Avoid confusion with the re we export.
File "/Users/kevin/.pyenv/versions/3.9.0/lib/python3.9/re.py", line 124, in <module>
import enum
File "/Users/kevin/Downloads/google-cloud-sdk/lib/third_party/enum/__init__.py", line 26, in <module>
spec = importlib.util.find_spec('enum')
AttributeError: module 'importlib' has no attribute 'util'
I think this is a Python issue. but I'm running Python3:
python -V shows
Python 3.9.0
I have installed it with homebrew.
What can be the problem?
This is a known issue across Mac, Windows and Linux: https://issuetracker.google.com/170125513.
I'd suggest to use the recommended Python versions mentioned here (3.5 to 3.8).
Also this does not affect only to Cloud SDK but others as well (for example as mentioned here).
Thanks for your answer. Indeed, it works with the version 3.8.6 of python.
I will add some infos if it can help somebody. In order to manage python version, I have used pyenv and installed the version of python I needed.
pyenv install 3.8.6
pyenv global 3.8.6
If you want a quick fix you can add this to your bash profile and restart your terminal:
export CLOUDSDK_PYTHON=python3.8
Worked for me

Keras_ocr fails to import

I am trying to use Keras_ocr for a project, but I can't get it to import to my script. I am using tensorflow backend (non-gpu).
Here is the error code I am receiving:
Traceback (most recent call last):
File "C:/Users/Cameron/PycharmProjects/NN-1/Test 1.py", line 5, in <module>
import keras_ocr
File "C:\Users\Cameron\Anaconda3\envs\TensorEnv\lib\site-packages\keras_ocr\__init__.py", line 1, in <module>
from . import (detection, recognition, tools, data_generation, pipeline, evaluation, datasets,
File "C:\Users\Cameron\Anaconda3\envs\TensorEnv\lib\site-packages\keras_ocr\detection.py", line 31, in <module>
from . import tools
File "C:\Users\Cameron\Anaconda3\envs\TensorEnv\lib\site-packages\keras_ocr\tools.py", line 14, in <module>
from shapely import geometry
File "C:\Users\Cameron\Anaconda3\envs\TensorEnv\lib\site-packages\shapely\geometry\__init__.py", line 4, in <module>
from .base import CAP_STYLE, JOIN_STYLE
File "C:\Users\Cameron\Anaconda3\envs\TensorEnv\lib\site-packages\shapely\geometry\base.py", line 18, in <module>
from shapely.coords import CoordinateSequence
File "C:\Users\Cameron\Anaconda3\envs\TensorEnv\lib\site-packages\shapely\coords.py", line 8, in <module>
from shapely.geos import lgeos
File "C:\Users\Cameron\Anaconda3\envs\TensorEnv\lib\site-packages\shapely\geos.py", line 145, in <module>
_lgeos = CDLL(os.path.join(sys.prefix, 'Library', 'bin', 'geos_c.dll'))
File "C:\Users\Cameron\Anaconda3\envs\TensorEnv\lib\ctypes\__init__.py", line 348, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found
I installed keras_ocr via pip.
This is a known issue where Keras_ocr finds the wrong DLL or can't find it at all. It can be solved simply by updating Keras_ocr or uninstalling and reinstalling keras_ocr.
Try installing Python=3.6 and the latest Tensorflow version, after that install keras_ocr.
That should work.

sklearn: Getting error while importing sklean in jupyter notebook

Importing sklearn gives error in anaconda jupyter notebook. I have installed scikitlearn package and issue is still seen.
Traceback (most recent call last):
File "version.py", line 18, in <module>
import sklearn
File "C:\ProgramData\Anaconda3\lib\site-packages\sklearn\__init__.py", line 13
4, in <module>
from .base import clone
File "C:\ProgramData\Anaconda3\lib\site-packages\sklearn\base.py", line 13, in
<module>
from .utils.fixes import signature
File "C:\ProgramData\Anaconda3\lib\site-packages\sklearn\utils\__init__.py", l
ine 11, in <module>
from .validation import (as_float_array,
File "C:\ProgramData\Anaconda3\lib\site-packages\sklearn\utils\validation.py",
line 18, in <module>
from ..utils.fixes import signature
File "C:\ProgramData\Anaconda3\lib\site-packages\sklearn\utils\fixes.py", line
144, in <module>
from scipy.sparse.linalg import lsqr as sparse_lsqr # noqa
File "C:\ProgramData\Anaconda3\lib\site-packages\scipy\sparse\linalg\__init__.
py", line 118, in <module>
from .matfuncs import *
File "C:\ProgramData\Anaconda3\lib\site-packages\scipy\sparse\linalg\matfuncs.
py", line 19, in <module>
import scipy.special
File "C:\ProgramData\Anaconda3\lib\site-packages\scipy\special\__init__.py", l
ine 640, in <module>
from ._ufuncs import *
ImportError: DLL load failed: The specified procedure could not be found.
(base) C:\Windows\system32>
As referred in this link that looks similar. You probably dont have c++ windows compiler. You will need to install Visual C++ Redistributable and then reinstalling anaconda might solve the issue.
On a side note anaconda generally takes care of the installing of the c++ compiler. Did you create virtualenv and pip install. I will suggest you install using conda install.
conda install scipy

Unable to import python packages in Ubuntu (ImportError : undefined symbol)

I recently installed python on my Ubuntu 14.04. I downloaded tensorflow by pip.
When I tried to import tensorflow it said ImportError:No module named tensorflow.
Then I edited PYTHONPATH by adding /usr/local/lib/python2.7/dist-packages. Now when I try to import, it says
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/__init__.py", line 23, in <module>
from tensorflow.python import *
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/__init__.py", line 45, in <module>
import numpy as np
File "/usr/local/lib/python2.7/dist-packages/numpy/__init__.py", line 180, in <module>
from . import add_newdocs
File "/usr/local/lib/python2.7/dist-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/usr/local/lib/python2.7/dist-packages/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/usr/local/lib/python2.7/dist-packages/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/usr/local/lib/python2.7/dist-packages/numpy/core/__init__.py", line 14, in <module>
from . import multiarray
ImportError: /usr/local/lib/python2.7/dist-packages/numpy/core/multiarray.so: undefined symbol: PyUnicodeUCS4_AsUnicodeEscapeString
I found here that 2 versions of python causes the conflict, but that didn't help. Any assistance will be appreciated. Thank you
Best way to install packages if you have more than one python installed is:
path_to_your_python_executable -m pip install package_name
This way, you can make sure that you have installed package for proper python.
And don't forget about sudo ;)

Installing numba onto Linux 7.0 - error with prerequisite llvmlite library diectory

I'm new to Linux and generally installing packages via command line syntax.
I've tried installing numba (to use jit) into Python and this is the error I receive.I did this originally with GitHub source, and again with Anaconda. Numba appear to be installed correctly in the command line, however when I try to import into Spyder I get the below error
llvmlite imports without error.
>>> import numba
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/numba-0.22.1_13.g1902d7f-py2.7-linux-x86_64.egg/numba/__init__.py", line 7, in <module>
from . import testing, decorators
File "/usr/local/lib/python2.7/dist-packages/numba-0.22.1_13.g1902d7f-py2.7-linux-x86_64.egg/numba/testing.py", line 6, in <module>
from numba import config
File "/usr/local/lib/python2.7/dist-packages/numba-0.22.1_13.g1902d7f-py2.7-linux-x86_64.egg/numba/config.py", line 9, in <module>
import llvmlite.binding as ll
File "/usr/local/lib/python2.7/dist-packages/llvmlite-0.0.0-py2.7.egg/llvmlite/binding/__init__.py", line 6, in <module>
from .dylib import *
File "/usr/local/lib/python2.7/dist-packages/llvmlite-0.0.0-py2.7.egg/llvmlite/binding/dylib.py", line 4, in <module>
from . import ffi
File "/usr/local/lib/python2.7/dist-packages/llvmlite-0.0.0-py2.7.egg/llvmlite/binding/ffi.py", line 43, in <module>
lib = ctypes.CDLL(_lib_name)
File "/usr/lib/python2.7/ctypes/__init__.py", line 365, in __init__
self._handle = _dlopen(self._name, mode)
OSError: libllvmlite.so: cannot open shared object file: No such file or directory

Categories