Can't launch Jupyter Notebook on osx - - python

I installed jupyter on my macbook pro (10.10), using pip install jupyter, it completed sucessfully. However, when trying to run the
jupyter notebook
command - I get the following errors.
Traceback (most recent call last):
File "/usr/local/bin/jupyter-notebook", line 11, in
sys.exit(main())
File "/Library/Python/2.7/site-packages/jupyter_core/application.py", line 267, in launch_instance
return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
File "/Library/Python/2.7/site-packages/traitlets/config/application.py", line 591, in launch_instance
app.initialize(argv)
File "<string>", line 2, in initialize
File "/Library/Python/2.7/site-packages/traitlets/config/application.py", line 75, in catch_config_error
return method(app, *args, **kwargs)
File "/Library/Python/2.7/site-packages/notebook/notebookapp.py", line 1008, in initialize
self.init_terminals()
File "/Library/Python/2.7/site-packages/notebook/notebookapp.py", line 908, in init_terminals
from .terminal import initialize
File "/Library/Python/2.7/site-packages/notebook/terminal/__init__.py", line 3, in <module>
import terminado
File "/Library/Python/2.7/site-packages/terminado/__init__.py", line 7, in <module>
logging.getLogger(__name__).addHandler(logging.NullHandler())
AttributeError: 'module' object has no attribute 'NullHandler'
Can you please advise..
per additional requested info
bash-3.2$ python --version
Python 2.7.10
bash-3.2$ echo $PYTHONPATH
bash-3.2$ which -a python
/usr/bin/python

Simpler installation with Anaconda
An alternative to using pip is Anaconda or Miniconda.
It is great for installing scientific libraries such as Jupyter.
Anaconda
Anaconda is a full distribution of about 200 libraries including Jupyter. Just install it with given instruction as user (not root) and you should be good to go.
Miniconda
Miniconda is smaller. It includes Python and a few essential libraries. If Anconda seems to big, download and install Miniconda. Again, as user not as root.
Then, install Jupyter with:
conda install jupyter

In your case it is complaining to the log file. If you can specify it it should solve the problem, as now it is not finding it.

Related

Spyder keeps crashing during load in all Anaconda environment

I was running python 2.7 in Anaconda2 in spyder 4 up until today with no problems. But now I keep getting the same error, when I make an environment and install python 2.7 and spyder in it:
Traceback (most recent call last):
File "/home/cmiprc/anaconda2/envs/test/lib/python2.7/site-packages/spyder/app/mainwindow.py", line 3718, in main
mainwindow = run_spyder(app, options, args)
File "/home/cmiprc/anaconda2/envs/test/lib/python2.7/site-packages/spyder/app/mainwindow.py", line 3557, in run_spyder
main = MainWindow(options)
File "/home/cmiprc/anaconda2/envs/test/lib/python2.7/site-packages/spyder/app/mainwindow.py", line 426, in init
from spyder.preferences.runconfig import RunConfigPage
File "/home/cmiprc/anaconda2/envs/test/lib/python2.7/site-packages/spyder/preferences /runconfig.py", line 482, in
class RunConfigPage(GeneralConfigPage):
File "/home/cmiprc/anaconda2/envs/test/lib/python2.7/site-packages/spyder/preferences/runconfig.py", line 487, in RunConfigPage
ICON = ima.icon('run')
File "/home/cmiprc/anaconda2/envs/test/lib/python2.7/site-packages/spyder/utils/icon_manager.py", line 394, in icon
directory=_resource['directory'])
File "/home/cmiprc/anaconda2/envs/test/lib/python2.7/site-packages/qtawesome/init.py", line 178, in load_font
return _instance().load_font(prefix, ttf_filename, charmap_filename, directory)
File "/home/cmiprc/anaconda2/envs/test/lib/python2.7/site-packages/qtawesome/init.py", line 54, in _instance
'materialdesignicons-webfont-charmap.json')
File "/home/cmiprc/anaconda2/envs/test/lib/python2.7/site-packages/qtawesome/iconic_font.py", line 206, in init
super().init()
TypeError: super() takes at least 1 argument (0 given)
This started happening after I reinstalled the package "pydicom" in the environment, and now nothing works. I have reinstalled anaconda2, used spyder --reset, and all other common suggestions.
Spyder 3.3.6 works in the base environment, but every time I make a new environment and install spyder in this, I get the same error. Any suggestions?
(Spyder maintainer here) To fix this problem, you need to install QtAwesome 0.7.3 in your environment. For that, please use the following command:
conda install qtawesome=0.7.3

How to incorporate matlab into jupyter notebook?

I am trying to integrate MATLAB and jupyter notebook so that I can use MATLAB in the web based notebooks and lab. I am running MATLAB R2020a, python 3.6 (from conda 4.8.2); the computer’s OS is Ubuntu 18.04. I am getting an error saying the MATLAB engine is not installed, though as far as I can tell it has been installed.
I have performed the following steps:
1. I made a conda environment with python 3.6 conda create matlab-conda python=3.6.
2. From there, I installed matlab_kernel using pip by typing in pip install matlab-kernel.
3. If I check that the kernel is installed by keying in jupyter kernelspec list and the view the lists, it says:
Available kernels:
ir /home/computerone/.local/share/jupyter/kernels/ir
matlab
/home/computerone/miniconda3/envs/matlab-conda/share/jupyter/kernels/matlab
python3
/home/computerone/miniconda3/envs/matlab-conda/share/jupyter/kernels/python3
To configure MATLAB, I located the extern/engines/python folder, and from within conda env ran the setup: python setup.py install. This successfully ran.
When I open the juyter notebook or lab, the MATLAB notebook option is there and I can select it, revealing a notebook; however, when I open a MATLABnotebook and type a command (e.g., 2+5), the following error is thrown:
[MetaKernelApp] ERROR | Exception in message handler:
Traceback (most recent call last):
File "/home/computerone/miniconda3/envs/matlab-conda/lib/python3.6/site-packages/ipykernel/kernelbase.py", line 268, in dispatch_shell
yield gen.maybe_future(handler(stream, idents, msg))
File "/home/computerone/miniconda3/envs/matlab-conda/lib/python3.6/site-packages/tornado/gen.py", line 735, in run
value = future.result()
File "/home/computerone/miniconda3/envs/matlab-conda/lib/python3.6/site-packages/tornado/gen.py", line 209, in wrapper
yielded = next(result)
File "/home/computerone/miniconda3/envs/matlab-conda/lib/python3.6/site-packages/ipykernel/kernelbase.py", line 541, in execute_request
user_expressions, allow_stdin,
File "/home/computerone/miniconda3/envs/matlab-conda/lib/python3.6/site-packages/metakernel/_metakernel.py", line 395, in do_execute
retval = self.do_execute_direct(code)
File "/home/computerone/miniconda3/envs/matlab-conda/lib/python3.6/site-packages/matlab_kernel/kernel.py", line 99, in do_execute_direct
retval = self._execute_async(code)
File "/home/computerone/miniconda3/envs/matlab-conda/lib/python3.6/site-packages/matlab_kernel/kernel.py", line 257, in _execute_async
future = self._matlab.eval(code, **kwargs)
File "/home/computerone/miniconda3/envs/matlab-conda/lib/python3.6/site-packages/matlab_kernel/kernel.py", line 81, in _matlab
""")
ImportError:
Matlab engine not installed:
See https://www.mathworks.com/help/matlab/matlab-engine-for-python.htm

Why do I have a Kernel Error in Jupyter Notebook?

I am a newbie to python. I am getting the below error in Kernel while opening jupyter notebook. Any ideas how I can resolve it? Installation of jupyter has been done via Anaconda3 - tried reinstalling and setting environment variables, but no luck so far. Any help would be greatly appreciated.
Traceback (most recent call last):
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\tornado\web.py", line 1699, in _execute
result = await result
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\notebook\services\sessions\handlers.py", line 72, in post
type=mtype))
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\notebook\services\sessions\sessionmanager.py", line 88, in create_session
kernel_id = yield self.start_kernel_for_session(session_id, path, name, type, kernel_name)
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\notebook\services\sessions\sessionmanager.py", line 101, in start_kernel_for_session
self.kernel_manager.start_kernel(path=kernel_path, kernel_name=kernel_name)
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 209, in wrapper
yielded = next(result)
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\notebook\services\kernels\kernelmanager.py", line 168, in start_kernel
super(MappingKernelManager, self).start_kernel(**kwargs)
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\jupyter_client\multikernelmanager.py", line 110, in start_kernel
km.start_kernel(**kwargs)
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\jupyter_client\manager.py", line 240, in start_kernel
self.write_connection_file()
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\jupyter_client\connect.py", line 547, in write_connection_file
kernel_name=self.kernel_name
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\jupyter_client\connect.py", line 212, in write_connection_file
with secure_write(fname) as f:
File "C:\Users\drag88\Anaconda3\lib\contextlib.py", line 112, in __enter__
return next(self.gen)
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\jupyter_client\connect.py", line 100, in secure_write
win32_restrict_file_to_user(fname)
File "C:\Users\drag88\AppData\Roaming\Python\Python37\site-packages\jupyter_client\connect.py", line 53, in win32_restrict_file_to_user
import win32api
ImportError: DLL load failed: The specified procedure could not be found.
Step 2 command: conda activate (location of your env folder)
Step 3 command: python -m ipykernel install --user
Works for Windows.
It looks like you had installed jupyter when there was an issue with its dependencies on Windows. See https://github.com/jupyterlab/jupyterlab/issues/7259 . I ran into the same error.
It should be fixed on conda now, so if you uninstall and reinstall jupyterlab from conda, it should not throw that error anymore.
I battled to get Jupyter working on my Windows 10 office computer for a number of hours. This was after installing Anaconda3. I had versions of Python 2 and 3 installed before. I was getting 'Kernel error' and also had various errors about 'win32api' and 'tornado'
I did many things but in the end main ones that, I think, helped are listed below -
On install, Anaconda3 created a data folder here -
C:\ProgramData\Anaconda3
I gave my user account access to write to this folder, I am not sure if it made a difference.
Elevated to admin, I copied two dll files as below -
pythoncom39.dll
pywintypes39.dll
From -
C:\ProgramData\Anaconda3\Lib\site-packages\pywin32_system32
To -
C:\windows\system32
At the 'Anaconda Prompt', a Windows cmd screen (which was added to my start menu) after the install, I did this -
(base) C:\>conda env create test-env
It created 'test-env' folder at C:\Users\{windows user name}\.conda\envs\test-env
(base) C:\>conda activate "C:\Users\{windows user name}\.conda\envs\test-env"
(test-env) C:\>
Once in this newly created environment, I tried various other things such as these -
conda install jupyter
conda install pywin32
python -m ipykernal install --user
Launching jupyter after loading and setting to this environment now works by using this command -
(test-env) C:\>jupyter notebook
When browser opens, select New>python 3 (ipykernel) from right hand menu to create new notebook.
If you have Python installed on your pc run from cmd or powershell:
pip install jupyterlab
Then you can start it with:
jupyter lab
The installation might have missed some steps which are fixed by post_install.
Go to yout venv's Script directory and run the command
python .\pywin32_postinstall.py -install
Make sure you are running the shell with Admin rights.
This error is sometimes as a result of the deleted environment that was created before. For Windows users, run the following code in cmd
python -m ipykernel install –user
Simply uninstall and install jupyter by first:
#Activate your environment in anaconda prompt (conda activate"path") and then type:-
conda uninstall jupyter
conda install jupyter

Cannot start jupyter notebook

When I try to start (any) jupyter notebook directly, I get the following error:
Traceback (most recent call last):
File "/usr/bin/jupyter-notebook", line 11, in <module>
sys.exit(main())
File "/usr/lib/python2.7/site-packages/jupyter_core/application.py", line 266, in launch_instance
return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
File "/usr/lib/python2.7/site- packages/traitlets/config/application.py", line 658, in launch_instance
app.start()
File "/usr/lib/python2.7/site-packages/notebook/notebookapp.py", line 1784, in start
self.launch_browser()
File "/usr/lib/python2.7/site-packages/notebook/notebookapp.py", line 1742, in launch_browser
with open(fd, 'w', encoding='utf-8') as fh:
TypeError: coercing to Unicode: need string or buffer, int found
However, if I only start jupyter on some directory, I can open notebooks through browser just fine.
jupyter version: 4.4.0
python version: 2.7.15
OS: Fedora 29
It was a problem introduced in notebook=5.7.3. Running with 5.7.2 works.
The problem was introduced in #4260 and backported to the 5.7.x branch in #4265.
Fix at #4340.
Fix should be part of notebook 5.7.5 when it is released.
More info at GitHub
Assuming you are using the Anaconda for Jupyter Notebook, try using the update option. Use the following code "conda update anaconda" in the Terminal.

'Module' has no attritube 'Treestyle'

If found some hits on stackoverflow where people have issues using ete3 tools when PyQT4 is not installed, and this (used to) also apply for me. However, I've now tried to reinstall a piece of software and it keeps complaining about 'Module' has no attritube 'Treestyle'.
To test whether PyQT was installed, I ran this python script:
from PyQt4.Qt import PYQT_VERSION_STR
print("PyQt version:", PYQT_VERSION_STR)
Which prints:
('PyQt version:', '4.12.1')
I get this (common) error:
Traceback (most recent call last):
File "/mnt/f/mypy/bin/virtualmicrobes.py", line 1820, in <module>
sys.exit(main())
File "/mnt/f/mypy/bin/virtualmicrobes.py", line 1793, in main
args.start(args)
File "/mnt/f/mypy/bin/virtualmicrobes.py", line 408, in start_evo_sim
result = init_and_simulate(simu, intermediate_load_file, _options)
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/my_tools/utility.py", line 117, in wrapper
raise ex_type(message)
AttributeError: 'module' object has no attribute 'TreeStyle' (in subprocess)
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/my_tools/utility.py", line 91, in process_func
ret = func(*args, **kwargs)
File "/mnt/f/mypy/bin/virtualmicrobes.py", line 295, in init_and_simulate
sim = sim_mod.create_simulation(**options)
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/simulation/Simulation.py", line 1940, in create_simulation
sim = ODE_simulation(params_dict)
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/simulation/Simulation.py", line 1342, in __init__
super(ODE_simulation, self).__init__(params)
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/simulation/Simulation.py", line 86, in __init__
self.init_graphs()
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/simulation/Simulation.py", line 795, in init_graphs
show=show, clean=clean, create=create)
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/plotting/Graphs.py", line 1188, in __init__
self.init_phylo_tree_graph(clean=clean)
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/plotting/Graphs.py", line 1219, in init_phylo_tree_graph
show=show, attribute_dict=self.attribute_mapper, create=clean, **kwargs)
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/plotting/Graphs.py", line 985, in __init__
self.init_tree_style_dict() # NOTE: unordered ok
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/plotting/Graphs.py", line 1110, in init_tree_style_dict
branch_vertical_margin=branch_vertical_margin)
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/plotting/Graphs.py", line 1083, in make_tree_style
ts = ete3.TreeStyle()
Note: this time arround I am trying to install it on Ubuntu for Windows, but up till now almost everything that ran on Linux ran on this one too. It might be relevent though.
Any ideas?
PS To reproduce the problem, follow the following steps:
$ sudo apt-get install python-qt4
$ virtualenv ~/mypy --system-site-packages
$ source ~/mypy/bin/activate
$ (mypy) > pip install VirtualMicrobes
$ (mypy) > virtualmicrobes evo --name TestMicrobes >> error
PPS User eyllanesc confirmed this is an 'Ubuntu for Windows' problem. I'm still trying to fix it though, if anyone can help me figure out how to link the pyqt4 packages correctly to my virtualenv that would be great. I've tried linken the native one with ln -s but I'm not getting any further
I had similar issues. The problem might be that you don't have all the depencies installed and ete3 is not telling you all of them.
You can see which dependencies are missing with this code:
import ete3
ete3.__file__
Run it and it will tell you which dependencies are missing. Note that you might need to run it multiple times before you install them all!

Categories

Resources