SageMath can't find jupyterthemes - python

I am running SageMath in MacOS with the built-in Jupyter notebook.
I have tried the following installation
(1) in terminal
sage -pip install jupyterthemes
(2) inside the jupyter notebook
!pip install jupyterthemes
!pip3 install jupyterthemes
!python3 -m pip install jupyterthemes
But in any case, running !jt in the notebook always returns
zsh:1: command not found: jt
I wonder how to make it work?

Related

Python Can't Connect to Kernel

My Jupyter Notebook will say connecting to kernel before not being able to make a connection.
To correct this I run.
python -m pip --proxy http://my_proxy_chain install --upgrade notebook
But while installing that, while it's collecting pywinpty>=1.1.0, I get:
ERROR: No matching distribution found for maturin<0.13,>=0.12.6
What troubleshooting steps should I attempt to get jupyter notebook talking to the kernel? I already installed maturin after getting this error - but that does not change the effect of getting it when I try to upgrade my notebook.
Try these steps;
create new environment using venv or conda env create -name <YOUR_ENV_NAME>
install dependancies. (You can even use pip install -r requirements.txt
for the jupyter kernel setup;
pip3 install jupyter ipykernel
python3 -m ipykernel install --user --name=new_kernel
new_kernel is the name of the kernel you need to select in the Jupyter notebook

Error when importing cv2 on anaconda prompt but it is working on jupyter notebook

I am importing libraries that I installed using pip install to Jupyter Notebook using the anaconda distribution, which is working. Next, I am trying to import the same libraries in the anaconda command prompt and running it. I am getting this error message:
ModuleNotFoundError: No module named 'cv2'
try these things:
First check if you are able to see your library by this command:
$ pip list or conda list
if not available install this module:
$ pip install opencv-python or conda install opencv-python
But before that, try to check numpy module is available or not. If numpy is not available, then install this first.
$ pip install numpy
If all of them exist then, Uninstall opencv-python and numpy first and upgrade your pip using the below command.
$ pip install --upgrade pip
Two options to install cv2 with the latest conda & python3:
Open the Anaconda Prompt and switch to your environment:
$ conda activate myenv
Then install opencv from the menpo channel:
$ conda install -c menpo opencv
Open the Anaconda Prompt with admin permission and make sure you're in the base environment:
$ conda activate base
Then install opencv from the menpo channel:
$ conda install -c menpo opencv
Reconnect your notebook to the kernel to import cv2.

How to install osmnx in Python?

I am trying to use osm library in Python. I found a recommended package called osmnx. I installed it via the command:
python -m pip install osmnx
when I type:
py -m pip freeze
I receive:
click==7.1.2
cycler==0.10.0
Flask==1.1.2
Flask-Ext==0.1
Flask-SQLAlchemy==2.4.4
itsdangerous==1.1.0
Jinja2==2.11.3
kiwisolver==1.3.1
MarkupSafe==1.1.1
matplotlib==3.3.4
numpy==1.20.1
osm==1.4
overpy==0.4
Pillow==8.1.0
pyparsing==2.4.7
python-dateutil==2.8.1
six==1.15.0
SQLAlchemy==1.3.23
Werkzeug==1.0.1
but osmnx is never there. Consequently when I run the code posted below, I receive the following error:
Traceback (most recent call last):
File "m:\python lessons\flask apps\osm\osmnx\test.py", line 1, in <module>
import osmnx as ox
ModuleNotFoundError: No module named 'osmnx'
Please let me know how to install osmnx in Python.
code:
import osmnx as ox
import matplotlib.pyplot as plt
place_name = "Kamppi, Helsinki, Finland"
graph = ox.graph_from_place(place_name)
Just to add to this, if you have installed osmnx using the above instructions , you will need to activate the environment each time you want to use it. To do this in anaconda prompt, type the following:
conda activate ox
This takes you from the base environment to the ox environment. You will then be able to execute the above code in anaconda prompt by typing
python myprogram.py
where myprogram.py is the name of your python program.
Older versions of osmnx installed into the base environment. However, this is not the case anymore it seems. I think there were some issues with package clashes or something.
I'm using OSMX inside of Blender which comes with its own Python distribution and Blender doesn't work well with Conda's python installs (Blender has its own python requirements). I got OSMX installed via Conda, but then Blender starting giving me all sorts of errors when using the Conda environment even following the suggestions on how to get Conda to work with Blender.
What I did is install all dependencies via pip, mindful of which version is the prereq as what is already installed may not be the version OSMX needs.
Then I installed OSMX via pip using a local wheel download from https://pypi.org/project/osmnx/#files (installing direct only had an old version and gave installation errors).
On Windows,
.\python -m pip install osmnx-1.3.0-py3-none-any.whl
After installing the pre-reqs, the wheel installed with no errors. If you have a dependency that isn't met - it will tell you and what specific version is needed.
In my case, while I had Shapely installed from another package, OSMX wanted 2.0 so I had to upgrade it using
.\python -m pip install shapely --upgrade
Hope this helps,
M
Try install with conda:
conda config --prepend channels conda-forge
conda create -n ox --strict-channel-priority osmnx
https://osmnx.readthedocs.io/en/stable/
You can find the answer in Installing OSMnx on Windows by Joshua Kobina Obeng article.
I will inlude the stesps as it is easy for you to see.
Open Anaconda command prompt(base) and type the following commands.
conda config --prepend channels conda-forge
conda create -n ox --strict-channel-priority osmnx
Then activate the enironment according to the instructions shown on the command prompt.
Open Anaconda Navigator.
In the "applications on" drop down, select "ox".
Instll Jupyter notebook by click on th install button given under "Jupyter Notebook".
After instllation complleted, launch Jupyter Notebook.
Open notebook and import osmnx.
If you want to install osnmx without conda try these steps:
From the OSMnx Github repo get the latest requirements.txt file
Install all requirements with pip command:
python3 -m pip install -r requirements.txt
Install osmnx with pip while all modules are satisfied:
python3 -m pip install osmnx

Import pandas is not working in Jupyter Notebook

I tried
pip install pandas on terminal
!pip install pandas on Jupyter Notebook
Creating new environment in anaconda then installing pandas again
conda install pandas nothing seems to work here
Try:
pip install --upgrade pip
pip install jupyter
then in jupyter notebook:
!pip install pandas
try installing the ipykernel:
conda isntall ipykernel
python -m ipykernel install --user --name myenv --display-name "Python (myenv)"

How to install mayavi on google Colab?

I tried installing mayavi on Colab using pip:
!pip install mayavi
This threw the following error:
Running setup.py bdist_wheel for mayavi ... error
The rest of the error output is available at the Colab document.
Solution: Work in Progress
Following the response from #Bob-Smith, I found that his solution needed a slight change for installing the dependencies:
!apt-get install vtk6
!apt-get install libvtk6-dev python-vtk6
Problems Faced and Workaround Found (PFWF)
PFWF-001 !apt-get install python-vtk throws the following error:
Package 'python-vtk' has no installation candidate
I found a command-reference for this:
!apt-get install libvtk5-dev python-vtk
However, this command also did not work. The package name had changed from libvtk5-dev to libvtk6-dev and the python binding for VTK has changed from python-vtk to python-vtk6. Clearly this kind of change will continue to happen in future and you may need to check the package name and the python binding for VTK before running the following statement:
!apt-get install libvtk6-dev python-vtk6
Note: If you are here looking to solve VTK installation problems for python and this does not solve that you may want to look here: installing-vtk-for-python
Installing mayavi still throws error:
Although the two steps above install the dependencies, the last line: !pip install mayavi spits out the following error:
Could not connect to any X display.
The latest progress on Mayavi installation can be found here.
https://colab.research.google.com/drive/1K_VIP9izNLKalD_IgBSiTowyNkU7aWcW
You'll first need to install deps. Run
!apt-get install vtk6
!apt-get install python-vtk
!pip install mayavi
If you've attempted to import myavi before installing the deps, you may need to restart you runtime before executing the !pip install myavi command using the Runtime -> Restart runtime menu.
I was trying to do the same thing and I was getting error like this. So I tried install vtk package with conda. You need conda to install vtk of course so:
!wget -c https://repo.anaconda.com/miniconda/Miniconda3-4.5.4-Linux-x86_64.sh
!chmod +x Miniconda3-4.5.4-Linux-x86_64.sh
!bash ./Miniconda3-4.5.4-Linux-x86_64.sh -b -f -p /usr/local
!conda install -q -y --prefix /usr/local python=3.6 ujson
import sys
sys.path.append('/usr/local/lib/python3.6/site-packages')
import ujson
print(ujson.dumps({1:2}))
!conda --version
Then set up vtk package with conda as:
!apt-get install vtk6
!conda install -c anaconda vtk
I was trying to install mayavi for mne package so:
!conda activate mne
!conda install gxx_linux-64=7.3
!pip install https://api.github.com/repos/enthought/mayavi/zipball/226189a6ad3dc3c01d031ef21d0d0cde554ac851
Be careful because you need to mne package to activate so before installing mayavi (I was trying to install mne as I said before):
!pip install mne

Categories

Resources