I have successfully downloaded zipline using conda but I keep getting this error when I try to import it into a program in jupyter notebook. I am relatively new to zipline so pardon me if the the solution is obvious. Please advise as I cannot find a solution anywhere and quantopian said this is an anaconda, not zipline issue.
Error:
~\Anaconda3\lib\site-packages\logbook\concurrency.py in <module>()
29
30 if has_gevent:
---> 31 from gevent._threading import (Lock as ThreadLock,
32 RLock as ThreadRLock,
33 get_ident as
thread_get_ident,
ImportError: cannot import name 'RLock
Successful install ==>
Solving environment: |
Warning: 4 possible package resolutions (only showing differing packages):
- anaconda::ca-certificates-2018.03.07-0, anaconda::openssl-1.0.2o-h8ea7d77_0
- anaconda::ca-certificates-2018.03.07-0, defaults::openssl-1.0.2o-h8ea7d77_0
- anaconda::openssl-1.0.2o-h8ea7d77_0, defaults::ca-certificates-2018.03.07-0
- defaults::ca-certificates-2018.03.07-0, defaults::openssl-1.0.2o-h8ea7d77done
Note: All requested packages are already installed.
This solution didn't work for me but it did work for others. tl;dr update logbook and uninstall gevent:
https://github.com/quantopian/zipline/issues/2208
=== My solution ===
Turns out my issue was basic environment handling. I had installed a conda env with python version 3.5, but ipython that was installed by default used python version 2.7. Solution:
conda install ipython
then running an example will not throw an error:
cd zipline/examples
ipython
%run buyapple.py
Related
This is a question from an absolute beginner of programing.
I tried the following codes on Google Colaboratory, and received the warning as written on the title of this post.
I restarted the runtime (which I believe worked successfully), but then when I retried the codes (by hitting 'run' button), I got the same warning.
Do you have any suggestion on how to fix this?
Thank you in advance.
!pip install torch torchvision
import torch
print('torch vision: ', torch.__version__)
!pip uninstall -y Pillow
!pip install Pillow==5.3.0
import PIL
print('pillow version: ', PIL.PILLOW_VERSION)
like so
You have to
uninstall/install modules
restart runtime
run code without uninstall/install
But first I would try code with the newest modules - without unistalling/installing.
Your tutorial is almost 1 year old and maybe it needed Pillow 5.3.0 at that momen. But it uses also Torch 0.4.0 and today we have 1.7.0 and it may work correctly with Pillow 7.0.0
I am trying to set up ortools on my Mac.
I installed via pip install ortools. I can verify that the package installed successfully.
conda list | grep ortools
WARNING: The conda.compat module is deprecated and will be removed in a future release.
ortools 7.1.6720 pypi_0 pypi
When I try to use the library, it looks like there are missing functions. I followed along with the example here:
https://developers.google.com/optimization/introduction/python
This returns an error:
from __future__ import print_function
from ortools.linear_solver import pywraplp
Traceback (most recent call last):
File "simple_ortools_example.py", line 2, in <module>
from ortools.linear_solver import pywraplp
ImportError: No module named ortools.linear_solver
I can import the module otherwise and look at the functions interactively:
>>> ortools.__
ortools.__cached__ ortools.__gt__( ortools.__path__
ortools.__class__( ortools.__hash__( ortools.__reduce__(
ortools.__delattr__( ortools.__init__( ortools.__reduce_ex__(
ortools.__dict__ ortools.__init_subclass__( ortools.__repr__(
ortools.__dir__( ortools.__le__( ortools.__setattr__(
ortools.__doc__ ortools.__loader__ ortools.__sizeof__(
ortools.__eq__( ortools.__lt__( ortools.__spec__
ortools.__file__ ortools.__name__ ortools.__str__(
ortools.__format__( ortools.__ne__( ortools.__subclasshook__(
ortools.__ge__( ortools.__new__( ortools.__version__
ortools.__getattribute__( ortools.__package__
I just used tab complete here to see what was available. Sure enough there is no linear_solver attached to the ortools module.
I'm a bit at a loss as to what to try next. Any advice would be apreciated.
I downgraded to an earlier version which solves the problem.
pip install ortools==6.7.4973
I faced the same issue today on Windows. Figured out that it is usually caused due to missing Microsoft Visual Studio 20** redistributables c++ (see here).
This is how I solved it (Python 3.7.6, ortools Version: 7.5.*).
Got the latest Microsoft Visual Studio 20** redistributables c++ from https://support.microsoft.com/en-my/help/2977003/the-latest-supported-visual-c
downloads
Installed it and Restarted the computer.
Uninstall the ortools 'python -m pip uninstall ortools'
Install back the ortools 'python -m pip install --user ortools'
Validated installation with python -c "from ortools.linear_solver import pywraplp"
I am currently using Python 3.5.5 on Anaconda and I am unable to import torch. It is giving me the following error in Spyder:
Python 3.5.5 |Anaconda, Inc.| (default, Mar 12 2018, 17:44:09) [MSC v.1900
64 bit (AMD64)]
Type "copyright", "credits" or "license" for more information.
IPython 6.2.1 -- An enhanced Interactive Python.
import torch
Traceback (most recent call last):
File "<ipython-input-1-eb42ca6e4af3>", line 1, in <module>
import torch
File "C:\Users\trish\Anaconda3\envs\virtual_platform\lib\site-
packages\torch\__init__.py", line 76, in <module>
from torch._C import *
ImportError: DLL load failed: The specified module could not be found.
Many suggestions on the internet say that the working directory should not be the same directory that the torch package is in, however I've manually set my working directory to C:/Users/trish/Downloads, and I am getting the same error.
Also I've already tried the following: reinstalling Anaconda and all packages from scratch, and I've ensured there is no duplicate "torch" folder in my directory.
Pls help! Thank you!
I had this similar problem in windows 10...
Solution:
Download win-64/intel-openmp-2018.0.0-8.tar.bz2 from https://anaconda.org/anaconda/intel-openmp/files
Extract it and put the dll files in Library\bin into C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin
Make sure your cuda directory is added to your %PATH% environment variable
I had the same problem. In my case I didn't want the GPU version of pytorch.
I uninstalled it. The version was pytorch: 0.3.1-py36_cuda80_cudnn6he774522_2 peterjc123.
The problem is that cuda and cudnn . then installed with the following command and now it works!
conda install -c peterjc123 pytorch-cpu
I also encountered the same problem when I used a conda environment with python 3.6.8 and pytorch installed by conda from channel -c pytorch.
Here is what worked for me:
1:) conda create -n envName python=3.6 anaconda
2:) conda update -n envName conda
3:) conda activate envName
4:) conda install pytorch torchvision cudatoolkit=9.0 -c pytorch
and then tested torch with the given code:
5:) python -c "import torch; print(torch.cuda.get_device_name(0))"
Note: 5th step will return your gpu name if you have a cuda compatible gpu
Summary: I just created a conda environment containing whole anaconda and then to tackle the issue of unmatched conda version I updated conda of new environment from the base environment and then installed pytorch in that environment and tested pytorch.
For CPU version, here is the link for my another answer: https://gist.github.com/peterjc123/6b804651288e76db7b5fabe5348e1f03#gistcomment-2842825
https://gist.github.com/peterjc123/6b804651288e76db7b5fabe5348e1f03#gistcomment-2842837
Had the same problem and fixed it by re-installing numpy with mkl (Intel's math kernel library)
https://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy
Download the right .whl for your machine. For me it was numpy‑1.14.5+mkl‑cp36‑cp36m‑win_amd64.whl (python 3.6, windows, 64-bit)
and then install using pip.
pip install numpy‑1.14.5+mkl‑cp36‑cp36m‑win_amd64.whl
I am using a Windows 10 computer with an NVIDIA GeForce graphics card. NVIDIA showed I had CUDA 10.1, but I was getting this error when running import torch in Jupyter Lab and suspected it had something to do with CUDA support.
I fixed this problem by downloading and installing the CUDA Toolkit directly from NVIDIA. It installed all required Visual Studio components. When I returned to Jupyter Lab, import torch ran without error.
Make sure you installed the right version of pytorch for your enviroment. I had the same problem I was using pytorch on windows but I had the default package installed which was meant for cuda 8. So I reinstalled the pytorch package for cpu which was what I needed.
I had the same issue with running torch installed with pure pip and solved it by switching to conda.
Following steps:
uninstall python 3.6 from python.org (if exists)
install miniconda
install torch in conda ("conda install pytorch -c pytorch")
Issue with pip installation:
import torch
File "C:\Program Files\Python35\lib\site-packages\torch\__init__.py", line 78, in <module>
from torch._C import *
ImportError: DLL load failed: The specified module could not be found.
After switching to conda it works fine. I believe the issue was resolved by conda through installing the vs_redist 2017
vs2017_runtime 15.4.27004.2010 peterjc123
But I have tried it w/o conda and it did not help. Could not find how to check (and tweak) Python's vs_redist.
Windows10 Solution(This worked for my system):
I was having the same issue in my system. Previously I was using Python 3.5 and I created a virtual environment named pytorch_test using the virtualenv module because I didn't want to mess up my tensorflow installation(which took me a lot of time). I followed every instruction but it didn't seem to work. I installed python 3.6.7 added it to the path. Then I created the virtual environment using:
virtualenv --python=3.6 pytorch_test
Then go to the destination folder
cd D:\pytorch_test
and activate the virtual environment entering the command in cmd:
.\Scripts\activate
After you do this the command prompt will show:
(pytorch_test) D:\pytorch_test>
Update pip if you have not done it before using:
(pytorch_test) D:\pytorch_test>python -m pip install --upgrade pip
Then go for installing numpy+mkl from the site:
https://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy
Choose the correct version from the list if you have python 3.6.7 go with the wheel file:
numpy‑1.15.4+mkl‑cp36‑cp36m‑win_amd64.whl (For 64 bit)
(Note if the whole thing doesnot work just go with simple numpy installation and mkl installation separately)
Then go for installing openmp using:
(pytorch_test) D:\pytorch_test>pip install intel-openmp
Now you are done with the prerequisites. To install pytorch go to the previous versions site:
https://pytorch.org/get-started/previous-versions/
Here select the suitable version from the list of Windows Binaries. For example I am having CUDA 9.0 installed in my system with python 3.6.7 so I went with the gpu version:
cu90/torch-1.0.0-cp36-cp36m-win_amd64.whl
(There are two available versions 0.4.0 and 1.0.0 for pytorch, I went with 1.0.0)
After downloading the file install it using pip(assuming the whl file is in D:).You have to do this from the virtual environment pytorch_test itself:
(pytorch_test) D:\pytorch_test>pip install D:\torch-1.0.0-cp36-cp36m-win_amd64.whl
Prerequisites like six, pillow will be installed automatically.
Then once everything is done, install the models using torchvision.
Simply type :
(pytorch_test) D:\pytorch_test>pip install torchvision
To check everything is working fine try the following script:
import torch
test = torch.rand(4, 7)
print(test)
If everything was good then it wont be an issue. Whenever there is an issue like this it is related to version mismatch of one or more dependencies. This also occurred during tensorflow installation.
Deactivate the following virtual environment using the command deactivate in the cmd:
(pytorch_test) D:\pytorch_test>deactivate
This is the output of pip list in my system:
Package Version
------------ -----------
intel-openmp 2019.0
mkl 2019.0
numpy 1.16.2
Pillow 6.0.0
pip 19.0.3
setuptools 41.0.0
six 1.12.0
torch 1.0.0
torchvision 0.2.2.post3
wheel 0.33.1
Hope this helps. This is my first answer in this community, hope you all find it helpful. I setup pytorch today in the afternoon after trying all sorts of combinations. The same import problem occurred to me while installing CNTK and tensorflow. Anyway I kept them separate in different virtual environments so that I can use them anytime.
I am using python 2.7.6 and trying to import pandas but Jupyter notebook gives me following
error--
ImportError Traceback (most recent call
last) in ()
----> 1 import pandas
/usr/local/lib/python2.7/dist-packages/pandas/init.py in
()
21
22 # numpy compat
---> 23 from pandas.compat.numpy import *
24
25 try:
/usr/local/lib/python2.7/dist-packages/pandas/compat/numpy/init.py
in ()
22 'your numpy version is {0}.\n'
23 'Please upgrade numpy to >= 1.9.0 to use '
---> 24 'this pandas version'.format(_np_version))
25
26
ImportError: this version of pandas is incompatible with numpy < 1.9.0
your numpy version is 1.8.2. Please upgrade numpy to >= 1.9.0 to use
this pandas version
while I have numpy 1.14.1
$ pip freeze
numpy==1.14.1
pandas==0.22.0
pip-magic==0.2.3
python-dateutil==2.6.1
pytz==2018.3
six==1.11.0
I have tried uninstalling and then reinstalling numpy and pandas from ubuntu terminal as well as Jupyter's terminal but unable to solve the error, any help would be appreciated. Thanks.
I could imagine that you have different versions of Python on your computer. In the Jupyter Notebook try running
import sys
sys.executable
This will show you which Python interpreter is used
EDIT:
You can install a new kernel for jupyter that uses the correct Python interpreter. First get a list of the existing kernels that you have:
Type jupyter kernelspec list. If the wanted interpreter is not there you will have to install it. To do so use python -m ipykernel install --name <Kernelname> --display-name <Displayname> Note that the python interpreter you are using to run this command must be the python interpreter that you want to be used by the kernel.
Now you are set up!
Start a new notebook and you will find that you can choose this new kernel
After trying multiple things I was able to resolve it.
The issue here was that python2.7 had older version of numpy i.e. 1.8.2 as the error in the question reports.
In python shell I found the path of numpy in use as follow.
import numpy
print numpy.__path__
the output was this path
/usr/local/lib/python2.7/dist-packages/numpy
went to /usr/local/lib/python2.7/dist-packages and deleted numpy using
sudo rm -r numpy
then staying in dist-packages directory I installed numpy 1.14.1 simply with pip.
sudo pip install numpy==1.14.1
this solved my problem.
One way to make sure that you use the right version or jupyter is the -m option of python:
-m mod : run library module as a script (terminates option list)
If this shows NumPy 1.14:
python -m pip freeze
starting jupyter like this should also give you the same version:
python -m jupyter notebook
you can find what versions of python are on your system and in what order they are searched with:
which -a python
Why don't you rm -rf the numpy library and install the version he is asking you too.
sudo pip install numpy==1.14.1
I would like to try zeroRPC but couldn't install the package properly. I am using the latest python_xy distribution (python 2.7.3) under windows 7 and I must say I don't have much experience with installing new modules since the distribution is allready pretty complete.
I pulled the master zeroRPC-python from gitHub and tried to do "python setup.py install"
I had a first problem with something like "impossible to locate vcvarsall.bat". I solved it by installing mingw as explained here error: Unable to find vcvarsall.bat
Then I could run the install untill the end, but now, when I import zerorpc, I get the following ImportError (only the end of the stack):
C:\Python27\lib\site-packages\gevent-0.13.8-py2.7-win32.egg\gevent\greenlet.py in <module>()
4 import traceback
5 from gevent import core
----> 6 from gevent.hub import greenlet, getcurrent, get_hub, GreenletExit, Waiter
7 from gevent.timeout import Timeout
8
C:\Python27\lib\site-packages\gevent-0.13.8-py2.7-win32.egg\gevent\hub.py in <module>()
28
29 try:
---> 30 greenlet = __import__('greenlet').greenlet
31 except ImportError:
32 greenlet = __import_py_magic_greenlet()
ImportError: No module named greenlet
I wonder more generally if I am following the right procedure to install new packages (under windows) or if there is a simpler way (safer with dependancies) that I would be overlooking (easy_install)? I must say I am very new to this and any hints or link to the relevant documentation would be appreciated.
Thanks in advance,
Samuel
I was struggling with this question myself for a while now. The solution involves several components, and many answers out there seem to relate to different versions of those components that don't always play well together.
Here is the complete solution that worked for me, starting from an empty virtualenv:
mkvirtualenv myenv
python -m pip install --upgrade pip==6.0.8 wheel==0.24.0
pip install gevent-1.0.1-cp27-none-win32.whl pyzmq-13.1.0-cp27-none-win32.whl zerorpc==0.4.4
The first step installs wheel and upgrades pip itself to support wheel package installations. The next step installs binary wheels for gevent-1.0.1 (downloadable from this unofficial but extremely useful python windows binaries page) and pyzmq-13.1.0 (available here), and the zerorpc-0.4.4 package from source in the usual way.
Note that I hard-coded source package versions here (pip 6.0.8, wheel 0.24.0, zerorpc 0.4.4) because as I said other versions don't always follow the same build patterns. This may not be necessary and future versions may prove to work just as well together.
The final result for me:
(myenv) C:\work>pip freeze
gevent==1.0.1
greenlet==0.4.5
msgpack-python==0.4.5
pyzmq==13.1.0
wheel==0.24.0
zerorpc==0.4.4
I used a slightly different way, I am using Anaconda + Jupyter to run my python notebooks.
I used this link to zerorpc package, and installed using
conda install -c groakat zerorpc
which installed following -