floWeaver does not draw basic diagrams from quick tutorial and does not show error message - sankey-diagram

Following the floWeaver tutorial and beginning with the Quickstart where flows are defined, the second step of plotting the flows does not work. The problem is that I do not get any error message.
The code consists of two blocks, with the second block not working..
import pandas as pd
flows = pd.read_csv('simple_fruit_sales.csv')
from ipysankeywidget import SankeyWidget
SankeyWidget(links=flows.to_dict('records'))
https://sankeyview.readthedocs.io/en/latest/tutorials/quickstart.html
Python version installed: 3.6.10
floWeaver version: 2.0.0
Many thanks in advance!

Just make sure that you have the following installation, other than the package itself.
pip install ipysankeywidget
jupyter nbextension enable --py --sys-prefix ipysankeywidget
jupyter nbextension enable --py --sys-prefix widgetsnbextension

Related

Python3.7: No module named

I've been trying to install matplotlib and textblob on my system using
pip3 install matplotlib
or
pip3 install textblob
It says it's installed successfully. However, when I try to import in in Sublime Text it says
ModuleNotFoundError: No module named 'matplotlib'
or
ModuleNotFoundError: No module named 'textblob'
I've set up the build system in sublime text for python 3. A lot of modules that I've installed and are using the same way works fine (BeautifulSoup, requests and tweepy for example). I do not understand why some modules work and others do not. I've been trying to find the solution to this problem but after hours of research without results, I see this question as my last resort. Very thankful for all help.
shell_cmd: /usr/bin/env python3

How to use Normal constructor correctly in pymc3?

When I use pymc3 to construct a normal distribution, I got error message. How to solve this problem?
I installed PyMC3 with windows Anaconda (version Anaconda3-2019.03-Windows-x86_64.exe). And running codes from official pymc3 tutorial "Getting started with PyMC3".
I tried to build a normal distribution with Normal constructor pm.Normal(). The codes are listed below
import numpy as np
import pymc3 as pm
basic_model = pm.Model()
with basic_model:
# Priors for unknown model parameters
alpha = pm.Normal('alpha', mu=0, sigma=10)
But got error message as the following:
AttributeError: module 'numpy.core.multiarray' has no attribute '_get_ndarray_c_version'
The problem is solved by removing theano 1.0.3 from Anaconda and performing pip install the latest version >=1.0.4.

No available image handler could decode this transfer syntax JPEG Lossless when read DICOM and ploting using matplotlib

When i use pydicom in python3.6, there are some problem:
import pydicom
import matplotlib.pyplot as plt
import os
import pylab
filePath = "/Users/zhuangrui/Documents/Python/Dicom/dicoms/zhang_bo/0001.dcm"
dataSet_1 = pydicom.dcmread(filePath)
plt.imshow(dataSet_1.pixel_array)
plt.show()
here is the problem:
How can this problem be solved? Thank you very much!
I've faced with the same problem, after doing some research on the suggested link above. I've managed to solve it by updating to the latest pydicom module "1.2.0" and installing gdcm. You can update the pydicom with
pip install -U git+https://github.com/pydicom/pydicom.git
You can find the latest gdcm here and this link explains the installation.
I use anaconda and it's easier to install the gdcm package and solve the problem. If you use anaconda
just type inside from your environment:
conda install pydicom --channel conda-forge to get pydicom's latest and
conda install -c conda-forge gdcm
to get the gdcm. This resolves the problem. Hope these will help.
With pydicom, you need an appropriate image handler also installed to handle compressed image types.
For JPEG lossless, in theory the following should work: jpeg_ls, gdcm, or Pillow with jpeg plugin. All of these also require Numpy to be installed. See the discussion at https://github.com/pydicom/pydicom/issues/532.
There is also a pull request in progress to add more descriptive error messages for what image handlers are needed for different images.
Problem:
I was trying to read medical images with .dcm extension. But was getting an error on Windows as well as on Ubuntu. I find a solution which will work on both the machined.
The error I got on Ubuntu is: NotImplementedError: this transfer syntax JPEG 2000 Image Compression (Lossless Only), can not be read because Pillow lacks the jpeg 2000 decoder plugin
(Note for Windows I was getting a different error but I am sure it's because of the same issue i.e. Pillow does not support JPEG 2000 format)
Platforma Information:
I am using: Python 3.6, Anaconda and Ubuntu, 15 GB RAM
RAM is important:
The solution I applied is the same as Ali explained above. But I want to add this installation may take time (depending on RAM you are using). On ubuntu where I am using 15 GB RAM on Cloud platform taken less time and on Windows on a local machine having 4 GB RAM taken a lot of time.
Solution
Anaconda is necessary. Why?
Please check the official doc of pydicom (https://pydicom.github.io/pydicom/dev/getting_started.html) its mentioned "To install pydicom along with image handlers for compressed pixel data, we encourage you to use Miniconda or Anaconda" (Note for Windows I was getting a different error)
If you are using Ubuntu directly open Terminal. If you are using Windows then on Anaconda Navigator go to Environment from here start terminal. Execute the following commands on it:
pip install -U git+https://github.com/pydicom/pydicom.git
conda install pydicom --channel conda-forge
conda install -c conda-forge gdcm
Cross Check:
Now use .dcm file for which we got the Error. Try to use the following code in Python notebook
filename = 'FileName.dcm'
ds = pydicom.dcmread(filename)
plt.imshow(ds.pixel_array, cmap=plt.cm.bone)
It should print the output. Also try this code:
ds.pixel_array
This will give you the array containing values.

bash: kivy: command not found

I followed the instructions in this link about Kivy installation "Using Homebrew with pip".
However, when I tried to run the code given below:
from kivy.app import App
from kivy.uix.button import Button
class TestApp(App):
def build(self):
return Button(text='Hello World')
TestApp().run()
It gave me an error:
bash: kivy: command not found
if you installed kivy with pip, you don't need a kivy command, you can use python directly.
python main.py
Because I created a virtual environment to isolate all the things that needs to be installed like kivy, and I installed cython and kivy first before the homebrew, it caused the problem. Even if I use:
python main.py
instead of
kivy main.py
What I did to solve it are the following:
1. Created a new virtual environment
2. Followed the instruction in kivy in right order: (1) homebrew, (2) Cython, then (3) Kivy.
3. Used "python" command instead of "kivy" command because I installed it using pip (refer to the commenr above). For example:
python name_of_your_file.py
Kivy documentation must be confusing that's why.

Installing numpy on mac with pip: "requirements already satisfied" but "No module numpy"

I have python2.7.8 on mac, things I did:
sudo easy_install pip - worked.
pip install numpy:
Requirement already satisfied (use --upgrade to upgrade): numpy in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
I also did "pip upgrade numpy" - no luck. What's wrong?
Your problem is a conflict of different Python versions.
I would recommend installing Python and all the packages, such as numpy, scipy, matplotlib, pandas, etc via Brew
See this tutorial: https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/Homebrew-and-Python.md
You can verify which Python you're running with which python or which python3 in Terminal.
This solution is more flexible and cleaner in my opinion than using Conda/Miniconda. However it is also a bit more lengthy to install, as you need to have Xcode, devtools installed to build everything
Could it be that you have multiple versions of python installed? What happens if you run python using the full path like this:
$ /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2
instead of just python2?
In my experience on Mac (and other OS too) it is best to go with Anaconda / Miniconda. This is especially true for packages like NumPy and others from scientific stack.
While Anaconda is a full-blown distribution with about 200 packages, Miniconda is just Python with a few basic libraries. The big advantage is that all packages install as binary. Further, it makes it very simple and stable to install multiple Python versions side by side. For example:
conda create -n py27 python=2.7
creates a new environment with Python 2.7. Activate with:
source activate py27
Now:
conda install numpy
installs NumPy cleanly.
You can do the same for Python 3.5 and switch between environments with source activate.
After jumping from one stackoverflow answer to another I found the solution!
my problems were:
numpy at different location( actually at right, expected-to-be location). It was the IDLE that looks for its own default folder where python2.7 installed.
I checked that my numpy is working like this, run this script to check it is working:
import os
import sys
import pygame
sys.path.insert(0, '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python')
import numpy
pygame.init()
print "( using __version__): " + numpy.__version__
print numpy.version.version
user_paths = os.environ['PYTHONPATH']
print(user_paths)
sys.path insertion adds additional path to IDLE, so it knows where to look for numpy.
Then I check if numpy truly imported - i just print its version. Right now it is 1.8.0rc.
I want to find a way to avoid using this syspath insertion all the time.
So far so good - for now.
I had a similiar problem with numpy. However, it was resolved by choosing the right environment. If you are using VScode, open the command palette (ctrl+shift+p) and type
Python: Select Interpreter.
From there, try choosing the right virtual environment/Interpreter.

Resources