Module not Found: zipline import - python

Getting the following stack trace from line:
zipline/zipline/__init__.py", line 17, in <module>
import numpy as np
ImportError: No module named 'numpy'
however, when I check pip list
pip list | grep numpy
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
numpy 1.16.6
This all occurs after I clone into the Quantopian/Zipline Github Repo.
I opened an issue on github, after this edit I'll search SO for anything obvious I missed.
Environment
WSL Ubunut Subsystem
Pyhon 3.5.5
Bitness: 64
installed dependencies via
sudo apt-get install libatlas-base-dev python-dev gfortran pkg-config libfreetype6-dev
Pip list
alembic 1.4.2
asn1crypto 0.24.0
bcolz 0.12.1
Bottleneck 1.3.2
certifi 2019.11.28
chardet 3.0.4
click 7.1.1
contextlib2 0.6.0.post1
cycler 0.10.0
cyordereddict 1.0.0
Cython 0.29.15
decorator 4.4.2
empyrical 0.5.3
enum34 1.1.6
funcsigs 1.0.2
idna 2.6
intervaltree 3.0.2
ipaddress 1.0.17
itable 0.0.1
keyring 10.6.0
Logbook 1.5.3
lru-dict 1.1.6
lxml 4.5.0
Mako 1.1.2
MarkupSafe 1.1.1
matplotlib 2.2.4
mercurial 4.5.3
mock 3.0.5
multipledispatch 0.6.0
networkx 1.11
numexpr 2.7.1
numpy 1.16.6
pandas 0.22.0
pandas-datareader 0.8.1
patsy 0.5.1
pinkfish 0.5.1
pip 19.3.1
pycrypto 2.6.1
pygobject 3.26.1
python-dateutil 2.8.1
python-editor 1.0.4
pytz 2019.3
pyxdg 0.25
requests 2.22.0
requests-file 1.4.3
scipy 1.2.2
SecretStorage 2.3.1
setuptools 39.0.1
six 1.14.0
sortedcontainers 2.1.0
SQLAlchemy 1.3.15
statsmodels 0.11.0
tables 3.5.2
toolz 0.10.0
trading-calendars 1.11.5
urllib3 1.25.7
wheel 0.30.0
zipline 1.3.0
WARNING: You are using pip version 19.3.1; however, version 20.0.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Update
running as a script, sudo python test.py returns
File "test.py", line 1, in <module>
import zipline
File "../zipline/zipline/__init__.py", line 29, in <module>
from .utils.run_algo import run_algorithm
File "../zipline/zipline/utils/run_algo.py", line 17, in <module>
from zipline.data import bundles
File "../zipline/zipline/data/bundles/__init__.py", line 2, in <module>
from . import quandl # noqa
File "../zipline/zipline/data/bundles/quandl.py", line 17, in <module>
from . import core as bundles
File "../zipline/zipline/data/bundles/core.py", line 14, in <module>
from ..adjustments import SQLiteAdjustmentReader, SQLiteAdjustmentWriter
File "../zipline/zipline/data/adjustments.py", line 24, in <module>
from ._adjustments import load_adjustments_from_sqlite
ImportError: No module named _adjustments

The issue arose due to the presence of multiple versions of python. Using the python -m pip install <packages> command inside of the zipline/zipline repo, I was able to successful execute import zipline inside a python shell

Related

keyring.get_password() throws NameError when reading credential from Windows Credential Manager

I am try to implement keyring on a windows system to manage database passwords for connection strings in pyodbc and sqlalchemy. I have tried to ensure the relevant packages from the NameError(s) thrown are installed.
Reason for manually setting the backend in keyring on windows
Here is the code I ran:`
from keyring.backends import Windows
import keyring
keyring.set_keyring(Windows.WinVaultKeyring())
keyring.get_password("Service", "Username")
Here are the errors thrown:
Traceback (most recent call last):
File ".\Python310\lib\site-packages\keyring\backends\Windows.py", line 109, in _get_password
res = win32cred.CredRead(
NameError: name 'win32cred' is not defined
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File ".\Python310\lib\site-packages\keyring\core.py", line 55, in get_password
return get_keyring().get_password(service_name, username)
File ".\Python310\lib\site-packages\keyring\backends\Windows.py", line 99, in get_password
res = self._get_password(service)
File ".\Python310lib\site-packages\keyring\backends\Windows.py", line 112, in _get_password
except pywintypes.error as e:
NameError: name 'pywintypes' is not defined
Installed packages are listed:
Package
Version
astroid
2.9.3
backcall
0.2.0
certifi
2021.10.8
cffi
1.15.0
charset-normalizer
2.0.12
cloudpickle
2.1.0
colorama
0.4.4
comtypes
1.1.11
cryptography
37.0.2
dask
2022.6.1
executing
0.8.3
fsspec
2022.5.0
greenlet
1.1.2
idna
3.3
ipython-genutils
0.2.0
isort
5.10.1
keyring
23.6.0
lazy-object-proxy
1.7.1
locket
1.0.0
mccabe
0.6.1
mistune
0.8.4
MouseInfo
0.1.3
numpy
1.22.3
opencv-python
4.5.5.64
packaging
21.3
pandas
1.4.1
partd
1.2.0
pickleshare
0.7.5
Pillow
9.1.1
pip
22.1.2
platformdirs
2.5.1
pure-eval
0.2.2
PyAutoGUI
0.9.53
pycparser
2.21
PyGetWindow
0.0.9
pylint
2.12.2
PyMsgBox
1.0.9
pyodbc
4.0.32
pyparsing
3.0.7
pyperclip
1.8.2
PyQt6
6.3.1
PyQt6-Qt6
6.3.1
PyQt6-sip
13.4.0
PyRect
0.2.0
PyScreeze
0.1.28
pytesseract
0.3.9
python-bidi
0.4.2
python-dateutil
2.8.2
pytweening
1.0.4
pytz
2022.1
PyWavelets
1.3.0
pywin32
303
pywin32-ctypes
0.2.0
pywinauto
0.6.8
PyYAML
6
requests
2.27.1
scipy
1.8.0
Send2Trash
1.8.0
setuptools
58.1.0
six
1.16.0
SQLAlchemy
1.4.39
sudo
1.0.0
tifffile
2022.3.16
toml
0.10.2
toolz
0.11.2
torch
1.11.0
torchaudio
0.11.0
torchvision
0.12.0
traitlets
5.1.1
typing_extensions
4.1.1
urllib3
1.26.9
wcwidth
0.2.5
webencodings
0.5.1
wrapt
1.13.3
This was an issue with extra python installations on my device.
I fixed this issue by deleting an extra set of python installations on my computer.
Create venv without admin access python
import keyring
keyring.set_keyring(Windows.WinVaultKeyring())
keyring.get_password("Service", "Username")
keyring.set_password("TestService","TestUser", "TestPassword")
keyring.get_password("TestService", "TestUser")
Prints:
'TestPassword'
Edit, this also fixes the need to set the default keyring.
I can omit: keyring.set_keyring(Windows.WinVaultKeyring())

How to find installed packaged through the command line and use them with Pycharm [duplicate]

This question already has answers here:
PyCharm doesn't recognize installed module
(23 answers)
How to cache downloaded PIP packages [duplicate]
(3 answers)
Closed 1 year ago.
I am starting to learn python, and I've been following courses using either command prompt or PyCharm.
I've been downloading packages through the command line prompt. Where can I find the installation directory and put it somewhere in PyCharm so that I don't have to download it twice?
To give an example, I just downloaded to matplotlib library using pip on the command line prompt as pip install maptlotlib. It got downloaded. When I then go to PyCharm - Setting - Python Environement, the maptlotlib package does not show up. How may I make it appear?
You need to choose this Python interpreter from PyCharm:
Settings > Project > Python interpreter.
It will show you every installed package.
use pip list you can get all installed package
bibo#esi09:~$ pip list
Package Version
---------------------- --------------------
attrs 19.3.0
Automat 0.8.0
blinker 1.4
certifi 2019.11.28
chardet 3.0.4
Click 7.0
cloud-init 21.1
colorama 0.4.3
command-not-found 0.3
configobj 5.0.6
constantly 15.1.0
cryptography 2.8
dbus-python 1.2.16
distro 1.4.0
distro-info 0.23ubuntu1
entrypoints 0.3
httplib2 0.14.0
hyperlink 19.0.0
idna 2.8
importlib-metadata 1.5.0
incremental 16.10.1
Jinja2 2.10.1
jsonpatch 1.22
jsonpointer 2.0
jsonschema 3.2.0
keyring 18.0.1
language-selector 0.1
launchpadlib 1.10.13
lazr.restfulclient 0.14.2
lazr.uri 1.0.3
MarkupSafe 1.1.0
meson 0.53.2
more-itertools 4.2.0
netifaces 0.10.4
oauthlib 3.1.0
pexpect 4.6.0
pip 20.3.3
pyasn1 0.4.2
pyasn1-modules 0.2.1
Pygments 2.3.1
PyGObject 3.36.0
PyHamcrest 1.9.0
PyJWT 1.7.1
pymacaroons 0.13.0
PyNaCl 1.3.0
pyOpenSSL 19.0.0
pyrsistent 0.15.5
pyserial 3.4
python-apt 2.0.0+ubuntu0.20.4.4
python-debian 0.1.36ubuntu1
PyYAML 5.3.1
requests 2.22.0
requests-unixsocket 0.2.0
SecretStorage 2.3.1
service-identity 18.1.0
setuptools 45.2.0
simplejson 3.16.0
simplelzo1x 1.1
six 1.14.0
sos 4.1
ssh-import-id 5.10
systemd-python 234
Twisted 18.9.0
ubuntu-advantage-tools 20.3
ufw 0.36
unattended-upgrades 0.1
urllib3 1.25.8
vtk 9.0.1
wadllib 1.3.3
wheel 0.34.2
zipp 1.0.0
zope.interface 4.7.1
WARNING: You are using pip version 20.3.3; however, version 21.1 is available.
You should consider upgrading via the '/usr/bin/python3 -m pip install --upgrade pip' command.
bibo#esi09:~$

ImportError: cannot import name 'validate' from jsonschema

I'm quite new in python and faced this issue after the manual installation of the new jsonschema dependency.
$ python /var/www/html/graylog.py
Traceback (most recent call last):
File "/var/www/html/graylog.py", line 18, in <module>
from jsonschema import validate
ImportError: cannot import name 'validate'
Python version 3.6.8
This is the current pip list
Package Version
------------------ --------
attrs 19.3.0
certifi 2019.3.9
chardet 3.0.4
Click 7.0
configparser 5.0.0
Flask 1.0.2
Flask-WTF 0.14.2
grapi 0.1.4
idna 2.8
importlib-metadata 1.6.1
itsdangerous 1.1.0
Jinja2 2.10
jsonschema 3.2.0
M2Crypto 0.35.2
MarkupSafe 1.1.1
Nuitka 0.6.8.3
pip 20.1.1
prometheus-client 0.8.0
PyMySQL 0.9.3
pyrsistent 0.16.0
PySimpleGUI 3.29.0
requests 2.21.0
setuptools 39.2.0
six 1.15.0
urllib3 1.24.1
virtualenv 16.4.3
Werkzeug 0.15.1
WTForms 2.2.1
zipp 3.1.0
Try to update the jsonSchema version that often solves the error especially if it's been installed manually
pip install --upgrade jsonschema
It may also be that the python that you are using in your environment may point to a different version that does not contain the jsonSchema module. Try
python3 /var/www/html/graylog.py

No module named tensorflow while i installed it with pip

I'm new to Tensorflow and machine learning. I'm following some tutorials on my PC, and everything worked just fine so far, importation and test with python are OK. I tried to test my code on my Macbook. So I installed Tensorflow, Matplotlib and Pandas using Pip3 on the command prompt. But when I ran the code on my Mac I got this :
Traceback (most recent call last):
File "test.py", line 3, in <module>
import tensorflow as ts
ModuleNotFoundError: No module named 'tensorflow'
There are the output and the Pip3 list :
Result of the pip install tensorflow
pip3 show tensorflow
gave me :
Name: tensorflow
Version: 2.0.0a0
Summary: TensorFlow is an open source machine learning framework for everyone.
Home-page: https://www.tensorflow.org/
Author: Google Inc.
Author-email: packages#tensorflow.org
License: Apache 2.0
Location: /usr/local/lib/python3.7/site-packages
Requires: google-pasta, gast, absl-py, astor, keras-preprocessing, keras-applications, six, numpy, wheel, grpcio, protobuf, tf-estimator-nightly, termcolor, tb-nightly
Required-by:
And :
pip3 list
gave me :
Package Version
-------------------- --------------------
absl-py 0.8.0
astor 0.8.0
cycler 0.10.0
gast 0.3.2
google-pasta 0.1.7
grpcio 1.23.0
h5py 2.10.0
Keras-Applications 1.0.8
Keras-Preprocessing 1.1.0
kiwisolver 1.1.0
Markdown 3.1.1
matplotlib 3.1.1
numpy 1.17.2
pandas 0.25.1
pip 19.1.1
protobuf 3.9.1
pyparsing 2.4.2
python-dateutil 2.8.0
pytz 2019.2
setuptools 41.0.1
six 1.12.0
tb-nightly 1.14.0a20190301
tensorflow 2.0.0a0
termcolor 1.1.0
tf-estimator-nightly 1.14.0.dev2019030115
virtualenv 16.7.5
Werkzeug 0.15.6
wheel 0.33.4
I did the exact same things on my Mac that I did on my PC, but I have more than one version of Python on my Mac, maybe this is the problem, but I just don't know how to solve it.
Sorry for my English, I'm not quit used to post on forum like these, and thanks for your help, I can give more information on my problem if you want.

No module named tensorflow.python on windows 10 when I run classify_image.py

I'm trying to use tensorflow to run classify_image.py, but I keep getting the same error:
Traceback (most recent call last):
File "classify_image.py", line 46, in <module>
import tensorflow as tf
File "C:\Users\Diederik\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\__init__.py", line 22, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
ModuleNotFoundError: No module named 'tensorflow.python'
Someone asked me to do a pip3 list, so I did:
C:\Users\Diederik\AppData\Local\Programs\Python\Python36\Scripts>pip3 list Package Version ----------- ------- absl-py 0.3.0 astor 0.7.1 gast 0.2.0 grpcio 1.13.0 Markdown 2.6.11 numpy 1.15.0 pip 10.0.1 protobuf 3.6.0 setuptools 39.0.1 six 1.11.0 tensorboard 1.9.0 tensorflow 1.9.0** termcolor 1.1.0 Werkzeug 0.14.1 wheel 0.31.1 You are using pip version 10.0.1, however version 18.0 is available. You should consider upgrading via the 'python -m pip install --upgrade pip' command.
I simply needed to add a python path, that was the only problem
try pip install --upgrade --ignore-installed tensorflow again.
If it said some packages can't be installed/upgrade for missing some other packages, pip installthose packages too, and try again the first code.
That's how I solved my problem.

Categories