cannot import zipline package after successful conda installation - python

python version -3.5.6
using anaconda, c++build tools are installed
pip install zipline works perfectly
import zipline # gives error below
(myenv) c:\users>>>pip show zipline
Name: zipline
Version: 1.4.1
Summary: A backtester for financial algorithms.
Home-page: https://zipline.io
Author: Quantopian Inc.
Author-email: opensource#quantopian.com
License: Apache 2.0
Location: c:\users\user\anaconda3\envs\ziplinerr\lib\site-packages
Requires: pip, setuptools, Logbook, click, six, python-interface, multipledispat
ch, toolz, numpy, pandas, pandas-datareader, scipy, patsy, statsmodels, empyrica
l, pytz, iso3166, trading-calendars, requests, sqlalchemy, alembic, bcolz, h5py,
tables, lru-dict, intervaltree, bottleneck, networkx, numexpr, iso4217
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\User\anaconda3\envs\ziplinerr\lib\site-packages\zipline\__init_
_.py", line 29, in <module>
from .utils.run_algo import run_algorithm
File "C:\Users\User\anaconda3\envs\ziplinerr\lib\site-packages\zipline\utils\r
un_algo.py", line 20, in <module>
from zipline.data import bundles
File "C:\Users\User\anaconda3\envs\ziplinerr\lib\site-packages\zipline\data\bu
ndles\__init__.py", line 2, in <module>
from . import quandl # noqa
File "C:\Users\User\anaconda3\envs\ziplinerr\lib\site-packages\zipline\data\bu
ndles\quandl.py", line 16, in <module>
from . import core as bundles
File "C:\Users\User\anaconda3\envs\ziplinerr\lib\site-packages\zipline\data\bu
ndles\core.py", line 15, in <module>
from ..minute_bars import (
File "C:\Users\User\anaconda3\envs\ziplinerr\lib\site-packages\zipline\data\mi
nute_bars.py", line 24, in <module>
import h5py
File "C:\Users\User\anaconda3\envs\ziplinerr\lib\site-packages\h5py\__init__.p
y", line 36, in <module>
from ._conv import register_converters as _register_converters
File "h5py\h5r.pxd", line 21, in init h5py._conv
File "h5py\_objects.pxd", line 12, in init h5py.h5r
File "h5py\_objects.pyx", line 1, in init h5py._objects
ImportError: DLL load failed: The specified procedure could not be found.

this worked for me:
# Create environment
conda create -n zipline_env python=3.6 ipykernel
# Activate environment, make sure you can see it in jupyter notebooks
conda activate zipline_env
python -m ipykernel install --user --name=zipline_env
# Install Zipline
conda install -c conda-forge zipline
If I swapped the order of the steps, it didn't work. After the above order is complete, then conda installing packages I want works fine, like jupyter, matplotlib, etc.

Related

how do install python packages using python3.11 -m pip

I am trying to install a python application (elastalert2) which requires the latest version of python on an Ubuntu 20.04 machine.
I have managed to install python3.11 and my searching suggested strongly that to install packages in this environment I should use python3.11 -m pip install but when I try I get:
elastalert#secmgrtst02:~$ /usr/bin/python3.11 -m pip install elastalert2==2.9.0
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "/usr/lib/python3/dist-packages/pip/__main__.py", line 16, in <module>
from pip._internal.cli.main import main as _main # isort:skip # noqa
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/pip/_internal/cli/main.py", line 10, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/usr/lib/python3/dist-packages/pip/_internal/cli/autocompletion.py", line 9, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/usr/lib/python3/dist-packages/pip/_internal/cli/main_parser.py", line 7, in <module>
from pip._internal.cli import cmdoptions
File "/usr/lib/python3/dist-packages/pip/_internal/cli/cmdoptions.py", line 19, in <module>
from distutils.util import strtobool
ModuleNotFoundError: No module named 'distutils.util'
I have very limited experience with python and do not know what the problem is.
I actually want the app installed in the current directory and initially (before I realised I need 3.11 I used pip3 install -t . elastalert3 which worked fine but would not run...
It is not recommended to install Python packages directly at the system level. It is recommended to install packages (libraries, dependencies) in a so-called "virtual environment".
So I would recommend you do the following:
python3.11 -m venv ~/my-python-environment
~/my-python-environment/bin/python -m pip install elastalert2==2.9.0
And from then on you call the python binary in that environment, to work with the library you just installed:
~/my-python-environment/bin/python -m elastalert.elastalert
You can create as many such environments as you need or want. You can place them wherever you want on your file system, but you can not move them after creation.
You can read more:
https://realpython.com/python-virtual-environments-a-primer/
https://docs.python.org/3/library/venv.html

Jupyter Labs ModuleNotFoundError: No module named 'traitlets.utils.descriptions'

I would like to install jupyter labs on my linux system. I have python3.9 installed so I run pip install jupyterlab as per official documentation.
After the download is finnished, I get the following error:
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
notebook 6.3.0 requires nbconvert==6.0.7, but you have nbconvert 6.5.0 which is incompatible.
notebook 6.3.0 requires nbformat==5.1.3, but you have nbformat 5.4.0 which is incompatible.
notebook 6.3.0 requires traitlets==4.3.3, but you have traitlets 5.3.0 which is incompatible.
Weird, but I have tried intalling all of these manually afterwards using pip install nbformat==5.1.3 and so on...
After the installation, I run jupyter lab, and the following error appers:
Traceback (most recent call last):
File "/root/venv/bin/jupyter-lab", line 5, in <module>
from jupyterlab.labapp import main
File "/root/venv/lib/python3.9/site-packages/jupyterlab/labapp.py", line 13, in <module>
from jupyter_server.serverapp import flags
File "/root/venv/lib/python3.9/site-packages/jupyter_server/serverapp.py", line 105, in <module>
from jupyter_server.gateway.managers import (
File "/root/venv/lib/python3.9/site-packages/jupyter_server/gateway/managers.py", line 25, in <module>
from ..services.sessions.sessionmanager import SessionManager
File "/root/venv/lib/python3.9/site-packages/jupyter_server/services/sessions/sessionmanager.py", line 20, in <module>
from jupyter_server.traittypes import InstanceFromClasses
File "/root/venv/lib/python3.9/site-packages/jupyter_server/traittypes.py", line 5, in <module>
from traitlets.utils.descriptions import describe
ModuleNotFoundError: No module named 'traitlets.utils.descriptions'
I have tried installing traitlets, but indeed when I run:
import traitlets
traitlets.utils.descriptions
I get:
AttributeError: module 'traitlets.utils' has no attribute 'descriptions'
Maybe this is the wrong version of the module? Which one should I install then?

import Spacy on RPI in Pycharm and other IDE gives error

I successfully installed Spacy using pip install spacy and alternatively through Pycharms virtual env, but when I import spacy in my program it's giving me the following error;
home/pi/.virtualenvs/cv/bin/python /home/pi/PycharmProjects/testSpeech/main.py
Traceback (most recent call last):
File "/home/pi/PycharmProjects/testSpeech/main.py", line 2, in <module>
import spacy
File "/home/pi/.virtualenvs/cv/lib/python3.7/site-packages/spacy/__init__.py", line 10, in <module>
from thinc.neural.util import prefer_gpu, require_gpu
File "/home/pi/.virtualenvs/cv/lib/python3.7/site-packages/thinc/neural/__init__.py", line 4, in <module>
from ._classes.model import Model # noqa: F401
File "/home/pi/.virtualenvs/cv/lib/python3.7/site-packages/thinc/neural/_classes/model.py", line 11, in <module>
from ..train import Trainer
File "/home/pi/.virtualenvs/cv/lib/python3.7/site-packages/thinc/neural/train.py", line 7, in <module>
from .optimizers import Adam, linear_decay
File "thinc/neural/optimizers.pyx", line 14, in init thinc.neural.optimizers
File "thinc/neural/ops.pyx", line 36, in init thinc.neural.ops
File "/home/pi/.virtualenvs/cv/lib/python3.7/site-packages/blis/__init__.py", line 3, in <module>
from .cy import init
ImportError: /home/pi/.virtualenvs/cv/lib/python3.7/site-packages/blis/cy.cpython-37m-arm-linux-gnueabihf.so: undefined symbol: __atomic_load_8
Process finished with exit code 1
Any idea what's happening?
You probably have a 32-bit OS? Instead, you will need a 64-bit OS with 64-bit python for spaCy v2, e.g.: https://downloads.raspberrypi.org/raspios_arm64/images/raspios_arm64-2020-08-24/
As of spacy v2.3.5 you should be able to install spacy in a venv for linux aarch64 with:
python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip setuptools
pip install spacy
Alternatively, there are binary linux aarch64 packages on conda-forge. There's a linux aarch64 miniforge installer and the install command would be conda install spacy. If you're not using the miniforge installer, then you need to add -c conda-forge or otherwise add the conda-forge channel.
See: https://github.com/explosion/spaCy/issues/6638
There was some problem while loading some library which was some prerequisite for spacy.
The problem was solved by calling the file via terminal with the following command;
LD_PRELOAD=/usr/lib/arm-linux-gnueabihf/libatomic.so.1.2.0 python3 main.py

Error importing tensorflow in Python 3 on Ubuntu 16.04 SyntaxError: l.append("%s=%s" % (attr, `value`))

I have python 3.5 installed on my Linux Mint (Ubuntu 16.04 Xenial)
I also had installed protobuf installed using pip3 install protobuf
I installed tensorflow using pip3 install tensorflow
Then I tried to import tensorflow in python 3 it failed with error presented below:
Traceback (most recent call last):
File "/home/abdullah/face_recognition/tensorflow_test.py", line 1, in <module>
import tensorflow
File "/usr/local/lib/python3.5/dist-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/__init__.py", line 83, in <module>
from tensorflow.python.estimator import estimator_lib as estimator
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/estimator/estimator_lib.py", line 35, in <module>
from tensorflow.python.estimator.inputs import inputs
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/estimator/inputs/inputs.py", line 22, in <module>
from tensorflow.python.estimator.inputs.numpy_io import numpy_input_fn
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/estimator/inputs/numpy_io.py", line 22, in <module>
from tensorflow.python.estimator.inputs.queues import feeding_functions
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/estimator/inputs/queues/feeding_functions.py", line 40, in <module>
import pandas as pd
File "/usr/local/lib/python3.5/dist-packages/pandas/__init__.py", line 23, in <module>
from pandas.compat.numpy import *
File "/usr/local/lib/python3.5/dist-packages/pandas/compat/__init__.py", line 361, in <module>
from dateutil import parser as _date_parser
File "/usr/local/lib/python3.5/dist-packages/dateutil/parser.py", line 158
l.append("%s=%s" % (attr, `value`))
^
SyntaxError: invalid syntax
Consulting through many questions posted on SO and other forums, I tried uninstalling protobuf then I encountered following error.
Traceback (most recent call last):
File "/home/abdullah/face_recognition/tensorflow_test.py", line 1, in <module>
import tensorflow
File "/usr/local/lib/python3.5/dist-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/__init__.py", line 52, in <module>
from tensorflow.core.framework.graph_pb2 import *
File "/usr/local/lib/python3.5/dist-packages/tensorflow/core/framework/graph_pb2.py", line 6, in <module>
from google.protobuf import descriptor as _descriptor
ImportError: No module named 'google.protobuf'
At the moment I'm just a beginner for all of this. I don't why protobuf is required why do all this hassle? I just wanted to get tensorflow installed on my system and try to learn something.
I was also facing the same problem. The problem I think is this is using pandas from system(apt-get) repository which is not compatible with other libraries. Updating pandas do the trick.
pip3 install --upgrade pandas
Also in your case, if only doing above fails, you can also try to reinstall tensorflow and protobuf with upgrade option.
pip3 install --upgrade protobuf
pip3 install --upgrade tensorflow
I just installed TensorFlow on my system today (Ubuntu 16.04 LTS) using VirtualEnv.
Did you run$ sudo apt-get install python3-pip python3-dev
If so, then try $ pip3 install -upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.4.0-cp35-cp35m-linux_x86_64.whl
Worst comes to worse, you could simply uninstall TensorFlow using $ sudo pip3 uninstall tensorflow and then try reinstalling to see if it corrects any errors.

Tensorflow pip built from source fails on 'import tensorflow'

Built tensorflow 0.7 from source on Ubuntu 15.10, Cuda 7.5, cudnn 4.0, python 2.7. Bazel build and pip package generation OK. pip install ok. Python script "import tensorflow" fails:
Traceback (most recent call last):
File "/home/keith/Desktop/tf1.py", line 8, in <module>
import tensorflow as tf
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 35, in <module>
from tensorflow.core.framework.graph_pb2 import *
File "/usr/local/lib/python2.7/dist-packages/tensorflow/core/framework/graph_pb2.py", line 16, in <module>
from tensorflow.core.framework import attr_value_pb2 as tensorflow_dot_core_dot_framework_dot_attr__value__pb2
File "/usr/local/lib/python2.7/dist-packages/tensorflow/core/framework/attr_value_pb2.py", line 16, in <module>
from tensorflow.core.framework import tensor_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__pb2
File "/usr/local/lib/python2.7/dist-packages/tensorflow/core/framework/tensor_pb2.py", line 16, in <module>
from tensorflow.core.framework import tensor_shape_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__shape__pb2
File "/usr/local/lib/python2.7/dist-packages/tensorflow/core/framework/tensor_shape_pb2.py", line 22, in <module>
serialized_pb=_b('\n,tensorflow/core/framework/tensor_shape.proto\x12\ntensorflow\"z\n\x10TensorShapeProto\x12-\n\x03\x64im\x18\x02 \x03(\x0b\x32 .tensorflow.TensorShapeProto.Dim\x12\x14\n\x0cunknown_rank\x18\x03 \x01(\x08\x1a!\n\x03\x44im\x12\x0c\n\x04size\x18\x01 \x01(\x03\x12\x0c\n\x04name\x18\x02 \x01(\tB/\n\x18org.tensorflow.frameworkB\x11TensorShapeProtosP\x01\x62\x06proto3')
TypeError: __init__() got an unexpected keyword argument 'syntax'
Any thoughts?
Thanks
This does look like a protobuf library versioning error. There's a long thread on similar issues here:
https://github.com/tensorflow/tensorflow/issues/11
Towards the end there are some suggested solutions that might help.
I succeed in running TensorFlow 0.7 on a manjaro linux laptop using cuda acceleration by running python with optirun:
$optirun python
However, I had problem with protobuf and I had to uninstall/reinstall previous version of protobuf and tensorflow with pip. http://bit.ly/1RHApU5
This is because of protobuf version conflict:
for me i had python-protobuf v2.6.1 installed from apt-get package manager
and while installing tensorflow it installed protobuf v3.3.0 from pip manager
so i uninstalled both:
sudo pip uninstall protobuf
sudo apt-get remove python-protobuf
Reinstalled using pip and it solved the issue!!!
sudo pip install protobuf
Hope this helps..

Categories

Resources