Why doesn't EC2 serve my jupyter notebook? - amazon-ec2

I set up my EC2 and I configured my jupyter notebook config file like here: https://chrisalbon.com/jupyter/run_project_jupyter_on_amazon_ec2.html.
I now run: jupyter notebook, and here's what I get:
[I 03:42:26.400 NotebookApp] Serving notebooks from local directory: /home/ec2-
user/courses/deeplearning1/nbs
[I 03:42:26.400 NotebookApp] 0 active kernels
[I 03:42:26.400 NotebookApp] The Jupyter Notebook is running at: https://[all ip addresses on your
system]:8888/
[I 03:42:26.400 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to
skip confirmation).
However, now that I'm trying to go to my site (http://ec2-54-202-213-129.us-west-2.compute.amazonaws.com:8888/), here's what I see on my terminal.
Exception in callback (<socket.socket fd=6, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('0.0.0.0', 8801)>, <function wrap.<locals>.null_wrapper at 0x7fc3e0210620>)
Traceback (most recent call last):
File "/home/ec2-user/anaconda3/lib/python3.6/site-packages/tornado/ioloop.py", line 887, in start
handler_func(fd_obj, events)
File "/home/ec2-user/anaconda3/lib/python3.6/site-packages/tornado/stack_context.py", line 275, in null_wrapper
return fn(*args, **kwargs)
File "/home/ec2-user/anaconda3/lib/python3.6/site-packages/tornado/netutil.py", line 272, in accept_handler
callback(connection, address)
File "/home/ec2-user/anaconda3/lib/python3.6/site-packages/tornado/tcpserver.py", line 244, in _handle_connection
do_handshake_on_connect=False)
File "/home/ec2-user/anaconda3/lib/python3.6/site-packages/tornado/netutil.py", line 513, in ssl_wrap_socket
context = ssl_options_to_context(ssl_options)
File "/home/ec2-user/anaconda3/lib/python3.6/site-packages/tornado/netutil.py", line 490, in ssl_options_to_context
context.load_cert_chain(ssl_options['certfile'], ssl_options.get('keyfile', None))
IsADirectoryError: [Errno 21] Is a directory
Any idea what I'm doing wrong?

At first did you try to use https:// instead http://? I.e. https://ec2-54-202-213-129.us-west-2.compute.amazonaws.com:8888/
Regardless of this I think you should follow the recommendations from official documentation: http://jupyter-notebook.readthedocs.io/en/latest/public_server.html#using-ssl-for-encrypted-communication
Create cert and key: openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mykey.key -out mycert.pem
Then start your notebook this way: jupyter notebook --certfile=mycert.pem --keyfile mykey.key

Related

Anaconda will not launch due to DLL load failure

I am trying to install/use Anaconda on my pc with Windows 10.
After installation, Anaconda will not launch.
If I enter anaconda-navigator in the Anaconda Command Prompt i receive the error included at bottom of post.
I tried to update conda to resolve using conda update conda, conda update anaconda-navigator, anaconda-navigator --reset
all of which render “environment variables: conda info could not be constructed. KeyError(‘pkgs_dirs’)”.
I tried conda info to find the .condarc file but received a DLL error.
I tried adding anaconda3\Scripts to path but that hasn’t helped.
Here's a pic of my path vars if it helps:
–DLL error msg
Traceback (most recent call last): File
“C:\Users\Penelope\anaconda3\Scripts\anaconda-navigator-script.py”,
line 6, in from anaconda_navigator.app.main import main File
“C:\Users\Penelope\anaconda3\lib\site-packages\anaconda_navigator\app\main.py”,
line 19, in from anaconda_navigator.app.start import start_app File
“C:\Users\Penelope\anaconda3\lib\site-packages\anaconda_navigator\app\start.py”,
line 27, in from anaconda_navigator.widgets.main_window import
MainWindow File
“C:\Users\Penelope\anaconda3\lib\site-packages\anaconda_navigator\widgets\main_window_init_.py”,
line 25, in from anaconda_navigator.api.anaconda_api import
AnacondaAPI File
“C:\Users\Penelope\anaconda3\lib\site-packages\anaconda_navigator\api\anaconda_api.py”,
line 30, in from anaconda_navigator.api.client_api import ClientAPI
File
“C:\Users\Penelope\anaconda3\lib\site-packages\anaconda_navigator\api\client_api.py”,
line 23, in import binstar_client File
“C:\Users\Penelope\anaconda3\lib\site-packages\binstar_client_init_.py”,
line 21, in from .mixins.channels import ChannelsMixin File
“C:\Users\Penelope\anaconda3\lib\site-packages\binstar_client\mixins\channels.py”,
line 7, in from binstar_client.utils import jencode File
“C:\Users\Penelope\anaconda3\lib\site-packages\binstar_client\utils_init_.py”,
line 14, in from .config import (get_server_api, dirs, load_token,
store_token, File
“C:\Users\Penelope\anaconda3\lib\site-packages\binstar_client\utils\config.py”,
line 90, in USER_LOGDIR = dirs.user_log_dir File
“C:\Users\Penelope\anaconda3\lib\site-packages\binstar_client\utils\appdirs.py”,
line 253, in user_log_dir return user_log_dir(self.appname,
self.appauthor, version=self.version) File
“C:\Users\Penelope\anaconda3\lib\site-packages\binstar_client\utils\appdirs.py”,
line 192, in user_log_dir path = user_data_dir(appname, appauthor,
version) File
“C:\Users\Penelope\anaconda3\lib\site-packages\binstar_client\utils\appdirs.py”,
line 68, in user_data_dir path = os.path.join(_get_win_folder(const),
appauthor, appname) File
“C:\Users\Penelope\anaconda3\lib\site-packages\binstar_client\utils\appdirs.py”,
line 280, in _get_win_folder_with_pywin32 from win32com.shell import
shellcon, shell ImportError: DLL load failed while importing shell:
The specified procedure could not be found.

failed to import pywin32 (even if it already installed) while starting supervisord in windows nanoserver container

I am trying to bring two process up in a windows Nanoserver container using supervisord (pip install supervisor-win )
Everything is setup in supervisord.conf, while starting it I am facing below issue,
C:\data>supervisord -n
C:\python-3.11.1-embed-amd64\Lib\site-packages\supervisor\options.py:480: UserWarning: Supervisord is running as root and it is searching for its configuration file in default locations (inc
luding its current working directory); you probably want to specify a "-c" argument specifying an absolute path to a configuration file for improved security.
self.warnings.warn(
Traceback (most recent call last):
File "C:\python-3.11.1-embed-amd64\Lib\site-packages\supervisor\loggers.py", line 220, in _disable_inheritance_filehandler
import win32api
oduleNotFoundError: No module named 'win32api'
D
uring handling of the above exception, another exception occurred:
T
raceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "C:\python-3.11.1-embed-amd64\Scripts\supervisord.exe\__main__.py", line 7, in <module>
File "C:\python-3.11.1-embed-amd64\Lib\site-packages\supervisor\supervisord.py", line 403, in main
go(options)
File "C:\python-3.11.1-embed-amd64\Lib\site-packages\supervisor\supervisord.py", line 415, in go
d.main()
File "C:\python-3.11.1-embed-amd64\Lib\site-packages\supervisor\supervisord.py", line 77, in main
self.options.make_logger()
File "C:\python-3.11.1-embed-amd64\Lib\site-packages\supervisor\options.py", line 1221, in make_logger
loggers.handle_file(
File "C:\python-3.11.1-embed-amd64\Lib\site-packages\supervisor\loggers.py", line 444, in handle_file
handler = RotatingFileHandler(filename, 'a', maxbytes, backups)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\python-3.11.1-embed-amd64\Lib\site-packages\supervisor\loggers.py", line 211, in __init__
self._disable_inheritance_filehandler() # fix file used by others process
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\python-3.11.1-embed-amd64\Lib\site-packages\supervisor\loggers.py", line 223, in _disable_inheritance_filehandler
raise ImportWarning("log rotation requires the installation of the \"pywin32\" library.\n"
ImportWarning: log rotation requires the installation of the "pywin32" library.
Download and install from https://github.com/mhammond/pywin32/releases
C:\data>
pywin32 module is already installed (tried reinstall with whl and pip anyway, that did not help)
C:\data>python -m pip show pywin32
Name: pywin32
Version: 305
Summary: Python for Window Extensions
Home-page: https://github.com/mhammond/pywin32
Author: Mark Hammond (et al)
Author-email: mhammond#skippinet.com.au
License: PSF
Location: C:\python-3.11.1-embed-amd64\Lib\site-packages
Requires:
Required-by: pypiwin32, supervisor-win
C:\data>
What could be the issue here? I see less dll files (around 400 only) in C:\Windows\System32 compared to servercore/server image (This is working fine with windows servercore image.)

OSError: [WinError 87] The parameter is incorrect: Jupyter & Anaconda

I am using Jupyter notebooks via anaconda. When saving a new notebook to a specific directory, the whole directory becomes inaccessible, showing this error (image and text below). Other directories and the notebooks inside them are still accessible and able to be run. I am able to save new notebooks and run them in other directories no problem.
Error:
Server error: Traceback (most recent call last): File "C:\Users\u1252652.conda\envs\DS011_loss_ratio\lib\site-packages\tornado\web.py", line 1704, in _execute result = await result File "C:\Users\u1252652.conda\envs\DS011_loss_ratio\lib\site-packages\tornado\gen.py", line 234, in wrapper yielded = ctx_run(next, result) File "C:\Users\u1252652.conda\envs\DS011_loss_ratio\lib\site-packages\notebook\services\contents\handlers.py", line 116, in get model = yield maybe_future(self.contents_manager.get( File "C:\Users\u1252652.conda\envs\DS011_loss_ratio\lib\site-packages\notebook\services\contents\filemanager.py", line 435, in get model = self._dir_model(path, content=content) File "C:\Users\u1252652.conda\envs\DS011_loss_ratio\lib\site-packages\notebook\services\contents\filemanager.py", line 309, in _dir_model for name in os.listdir(os_dir): OSError: [WinError 87] The parameter is incorrect: 'C:\Users\u1252652\OneDrive - MMC\Documents\DS011_loss_ratio'
This is strange as i have been working in this directory and saving numerous notebooks to it without error until today. I can delete the notebook that caused it to crash and then it returns to normal and i can run notebooks that were already saved before today.
I am unsure if this is related or not but i also have an issue whereby i have to run python -m ipykernel install --user every time i change to a new environment in anaconda, otherwise the executable remains as that of the last environment i ran that command with. Perhaps this is useful i'm not sure, if anyone had advice with this too i'd be grateful.
I have also tried making a new directory, copying over the contents of the dysfunctional directory, and then making a new notebook from there, however this causes the same error.

Anaconda Jypiter wont start, Spyder reporting errors

I did try uninstalling and installing Anaconda, but the problem remains the same.
Windows 10 x64, latest Anaconda
Installation goes fine, but when I start Spyder it reports this:
"You have missing dependencies, nbconvert >=4.0": None. However, nbconvert is already installed.
It prompted me to install Kite, when I did it says Kite installation error.
When I try to launch jupyter lab I get this:
Traceback (most recent call last): File
"C:\Users\Aleksandar\anaconda3\Scripts\jupyter-lab-script.py", line 5,
in from jupyterlab.labapp import main File
"C:\Users\Aleksandar\anaconda3\lib\site-packages\jupyterlab\labapp.py",
line 14, in from jupyterlab_server import slugify,
WORKSPACE_EXTENSION File
"C:\Users\Aleksandar\anaconda3\lib\site-packages\jupyterlab_server__init__.py",
line 4, in from .app import LabServerApp File
"C:\Users\Aleksandar\anaconda3\lib\site-packages\jupyterlab_server\app.py",
line 9, in from .server import ServerApp File
"C:\Users\Aleksandar\anaconda3\lib\site-packages\jupyterlab_server\server.py",
line 14, in from notebook.base.handlers import ( File
"C:\Users\Aleksandar\anaconda3\lib\site-packages\notebook\base\handlers.py",
line 22, in from tornado import web, gen, escape, httputil File
"C:\Users\Aleksandar\anaconda3\lib\site-packages\tornado\web.py", line
87, in from tornado.httpserver import HTTPServer File
"C:\Users\Aleksandar\anaconda3\lib\site-packages\tornado\httpserver.py",
line 32, in from tornado.http1connection import
HTTP1ServerConnection, HTTP1ConnectionParameters File
"C:\Users\Aleksandar\anaconda3\lib\site-packages\tornado\http1connection.py",
line 34, in from tornado import iostream File
"C:\Users\Aleksandar\anaconda3\lib\site-packages\tornado\iostream.py",
line 40, in from tornado.netutil import ssl_wrap_socket,
_client_ssl_defaults, _server_ssl_defaults File "C:\Users\Aleksandar\anaconda3\lib\site-packages\tornado\netutil.py",
line 39, in
_client_ssl_defaults = ssl.create_default_context(ssl.Purpose.SERVER_AUTH) File
"C:\Users\Aleksandar\anaconda3\lib\ssl.py", line 589, in
create_default_context context.load_default_certs(purpose) File
"C:\Users\Aleksandar\anaconda3\lib\ssl.py", line 490, in
load_default_certs self._load_windows_store_certs(storename, purpose)
File "C:\Users\Aleksandar\anaconda3\lib\ssl.py", line 482, in
_load_windows_store_certs self.load_verify_locations(cadata=certs) ssl.SSLError: nested asn1 error (_ssl.c:4003)
Found an error. It is caused by the certificates issued by Serbian government. The solution is changing ssl.py like this:
def _load_windows_store_certs(self, storename, purpose):
certs = bytearray()
try:
for cert, encoding, trust in enum_certificates(storename):
# CA certs are never PKCS#7 encoded
if encoding == "x509_asn":
if trust is True or purpose.oid in trust:
if "MUP Republike Srbije" not in str(cert):
certs.extend(cert)
except PermissionError:
warnings.warn("unable to enumerate Windows certificate store")
if certs:
self.load_verify_locations(cadata=certs)
return certs`

IOError: [Errno 13] Permission denied when trying to import and use plotly

I am running a flask application using plotly for some of my charting figures, and it runs fine on my work pc.
I have just tried to run it on my personal pc and on starting the local host server I am getting the following message:
Traceback (most recent call last):
File "controller.py", line 14, in <module>
from plotly.offline import plot
File "C:\Users\StuJ7\Anaconda2\lib\site-packages\plotly\__init__.py", line 31, in <module>
from plotly import (plotly, dashboard_objs, graph_objs, grid_objs, tools,
File "C:\Users\StuJ7\Anaconda2\lib\site-packages\plotly\plotly\__init__.py", line 10, in <module>
from . plotly import (
File "C:\Users\StuJ7\Anaconda2\lib\site-packages\plotly\plotly\plotly.py", line 29, in <module>
from plotly import exceptions, files, session, tools, utils
File "C:\Users\StuJ7\Anaconda2\lib\site-packages\plotly\tools.py", line 403, in <module>
#utils.template_doc(**get_config_file())
File "C:\Users\StuJ7\Anaconda2\lib\site-packages\plotly\tools.py", line 241, in get_config_file
ensure_local_plotly_files() # make sure what's there is OK
File "C:\Users\StuJ7\Anaconda2\lib\site-packages\plotly\tools.py", line 94, in ensure_local_plotly_files
utils.save_json_dict(fn, contents)
File "C:\Users\StuJ7\Anaconda2\lib\site-packages\plotly\utils.py", line 61, in save_json_dict
with open(filename, "w") as f:
IOError: [Errno 13] Permission denied: 'C:\\Users\\StuJ7\\.plotly\\.credentials'
So it's obvious from the error message that it is an issue with permissions regarding the .plotly.credentials file - but I have assigned myself full permissions to the whole .plotly folder through the security settings and I have also pip installed plotly as an administrator.
I've tried extensive Googling , but there doesn't seem to be much windows related advice regarding this particular issue.
Can anyone suggest how I can get this to work.

Resources