Python 2.7 not working -- refusing to serve hidden directly , via 404 Error - python-2.7

CMD error message
jupyter 404 error message
I was able to work fine with python (jupyter notebook) until yesterday, and I turned off the command prompt that was running python. When I try to restart python by typing in jupyter notebook in cmd, it throws a 404 error. I think the possible reason for this is that I was running python as a server and connecting it to asp.net website in visual studio with IIS running the asp.net. So the python server on port 8888 might still be running, and I think that is what's preventing me from opening jupyter notebook.
So I tried the following steps to get it to work, but it throws the same error:
Pressed ctrl+c twice to interrupt the kernel (interuppted but still did not run jupyter notebook afterwards)
Uninstalled Python 2.7 Anaconda and reinstalled
Removed IIS website and tried running python by itself (still not worked)
My question comes down to this:
How do I get the jupyter notebook to run? Should I try closing the port 8888 and running jupyter notebook again?

In case someone faces the same issue, I am posting an answer to my question :)
Answer:
Open Anaconda prompt then type in "jupyter notebook"

Related

Jupyter notebook hanging due to Django runserver

Some time ago I made a simple Django application. Recently, I started using Jupyter notebooks for Python and was wondering if I could run my application from such a notebook. To test that, I opened a new notebook and navigated to the top directory of the application:
%cd d:\adressen
To see if the application could be run from the notebook, I first tried:
!py manage.py makemigrations
It returned, as it should:
No changes detected
So far so good. Now starting the server:
!py manage.py runserver
In a sense nothing happend. No output, the cell label still showing as In[*]. Nevertheless, the server was running, for if I opened in my webbrowser the page http:\\localhost:8000, my application turned up and all features were working.
I fail to see why in the notebook makemigrations is handled correctly and runserver makes it hanging. The Jupyter console did not show anything that could have gone wrong.
Having looked at some other questions and answers about Jupyter and Django, I installed django-extensions and included it in the installed apps. That did not help. When I start Jupyter with python manage.py shell_plus --notebook, open a new notebook and use the same commands, the same happens.
Any suggestions on why this happens and how to overcome it are highly appreciated.
At last I think I found what is going on here and how to overcome it.
With the Jupyter shell command !py manage.py runserver Django indeed starts the server, but also wants to write to a console. There is no console, so Jupyter seems to hang.
When instead we use !start py manage.py runserver, not only Django starts the server, but also a console opens in which we see the standard Django output when opening a server.
In this way I can use a Jupyter notebook as an IDE for Django projects.

Django webserver automatically shuts off on local server when I try to access the admin section

I'm a noob trying to learn Django for the first time, I created a project in a virtualenv on Windows 10. It worked well in the beginning where I was able to login to the admin section after running '''python manage.py runserver'''
But now when I run the same command I'm able to see the Django landing page but as soon as I try to hit http://localhost:8000/admin/ or http://127.0.0.1:8000/admin the server automatically disconnects and I get the "This site can’t be reached" error on Chrome.
I tried changing the port number by running python manage.py runserver 0.0.0.0:8001 but it didn't work. I tried to check if the port (8000) is currently in use by running the cmd (as an admin) netstat -a -b but couldn't find any issues.
The server just quits without any error message
Edit: Currently using Python 3.7.0 and django-3.0.1
There's a ticket about this issue: https://code.djangoproject.com/ticket/31067.
This seems to be a bug in Python 3.7.0, and appears to be fixed in Python 3.7.1. It's still unknown what the exact trigger is for this bug.
Since Django officially only supports the latest patch release of a Python series, this won't be fixed in Django. You can either upgrade your Python version to the latest patch release of 3.7, or downgrade Django to 2.2.
It's a Django 3.0 issue as I've seen. There are so many issues on GitHub, regarding this error.
You may try downgrading to Django 2.* versions for now. Version 2.1/2.2 works fine.

Is it possible to SSH in AWS instances using any IDEs such PYCHARM?

I am stuck in a technical issue on a project and I think you the forum could help me out.
I have an EC2 Instance Type:p2.xlarge running on AWS, I cloned a repository in this instance which requires pytorch and cuda dependencies(this point has been taken care of).
Now, The issue is that I wanna work & run this code-base(which is is AWS instance now) somehow in my local pyCHARM IDE. In short, I didn't have proper resources on my laptop to run the repository, so I have to run in an AWS instance but for debugging purposes the local IDE would be a great option.
Is it possible to do that?. In other words, we can do SSH into AWS instance and run code, but all will be done through command line, if we could SSH through PYCHARM and can see the code in AWS here in local machine within PYCHARM and change, debug or run it as it was local but actually it gets executed in the instance.
Please suggest a solution to it.
Thanks in advance.
EDIT-1:
After following, #Cromulent suggestion, I have arrived here
Setting the remote:
Upload happening within the local & remote repo.
I still didn't understand the requirement of syncing the local and remote folders, when I only want to open the remote folder in my PYCHARM IDE and work on it.
I think after this setup, I have to change the code in local copy and the PYCHARM will sync the code in remote copy. How will I be running(using resources-GPUs of the remote Instance, not my local machine.) the remote code in PYCHARM in this scenario, I am just syncing it, for running again I have to ssh through command line and run the script(This does not serve the purpose)?
EDIT-2:
After #Cromulent suggestions.
Actually, it did work, but still, I am not able to run the remote code locally.
I am getting the below error while running any remote script. If I run the same script using ssh in the terminal, the scripts run normally. I tried to fix the problem using this post on StackOverflow, but it didn't work too.
ssh://ubuntu#ec2-52-41-247-169.us-west-2.compute.amazonaws.com:22/home/ubuntu/anaconda3/bin/python -u <08ad9807-3477-4916-96ce-ba6155e3ff4c>/home/ubuntu/InsightProject/scripts/download_flownet2.py
/home/ubuntu/anaconda3/bin/python: can't open file '<08ad9807-3477-4916-96ce-ba6155e3ff4c>/home/ubuntu/InsightProject/scripts/download_flownet2.py': [Errno 2] No such file or directory
The below is the screenshot for the above problem:
PyCharm Professional supports remote Python interpreters (either the globally installed Python interpreter or a virtualenv). It works by creating an SSH connection to the server and then running the code on the remote host. The results are then displayed locally in PyCharm Professional. You can also do remote debugging as well.
You MUST be using the professional version of PyCharm though. The free community version does not support this feature.
You can find the documentation here:
https://www.jetbrains.com/help/pycharm/configuring-remote-interpreters-via-ssh.html
One more solution is to deploy a Jupyter Notebook on your remote server. Then you will be able to use it from PyCharm Professional Edition.
Don't forget to make rules for the jupyter ports (e.g. allow all 8888) in your AWS console and in your instance.
To configure a remote interpreter for your notebook do this (source):
Open the Jupyter Notebook page of the Settings/Preferences dialog.
On this page, select or clear the Markdown cells rendering enabled option, and specify the username and password. Note that for the
single-user notebooks these fields are optional - leave them blank.
Fill in the username (for JupyterHub) and password.
Click the link Configure remote interpreter. You'll find yourself at the Project Interpreter page.
Configure the remote interpreter, as described in the section Configuring Python Interpreter.
You will want to configure a remote interpreter.
I tried the above approach but it didn't work for me. I have edited my post so that I can get additional input from the community, but I didn't any after the first answer was posted.
My friend actually figured out a secondary way to fix the issue. He actually uses "NOMACHINE" on the local machine and open connection to the remote desktop. Then you can directly install PYCHARM in the remote machine and work in there. I hope this will help others.
The solution is in his blog post. (Thanks to Shaobo Guan)
Another solution would be to use VNC instead of NoMachine

Syntax error when trying to run debug configuration for remote interpretor from PyCharm

I'm setting up a Google App Engine Django project to run in a Vagrant environment for easy setup/teardown of the system and am using PyCharm as the IDE for it all. I'm able to successfully get the server to run using PyCharm on the remote machine, but if I try to use the remote debugger to start a debug session, PyCharm gives me a nondescript error:
Error running webapp: Can't run remote python interpreter: Couldn't obtain remote socket from output , stderr File "", line 1
import
^
SyntaxError: invalid syntax
I'll try to include as much info about the setup as I can:
Windows 10 host machine, Ubuntu 14.04 guest
Python is version 2.7.10
/home/vagrant/www/shell/python-su.sh setup as python interpreter. Just passing arguments to sudo /usr/bin/python $# to make it work in vagrant/GAE
GAE Directory in PyCharm is set to /home/vagrant/google_appengine/ to make it work on the remote machine
Here's a screenshot of my PyCharm Configuration Settings for launching debug client:
All of this matches what I do for the run configuration and that works fine. It's only the debug configuration throwing this error.
From the help documentation for PyCharm, I found this article detailing how to turn on more logging to the PyCharm log file. Add this to the log.xml file located in the /bin/ directory of the PyCharm Program Files directory:
<category name="#com.jetbrains.plugins.webDeployment">
<priority value="DEBUG"/>
</category>
Looking at the log file showed what command it was trying to run, which I was able to run by SSH-ing into the machine to run it myself. From there, I was able to figure it it was coming from my sudo python file. I had to wrap the $# in quotes to get it to work properly. The run was working because the arguments were simple enough that it didn't matter that it wasn't quoted. The final python sudo shell file looks like this:
sudo /usr/bin/python "$#"

VMC tunnel crash

I'm trying to execute vmc tunnel but i get error 'ruby interpreter has stopped working' . Tryed to find what's the problem on the Internet but the only solution i saw was to upgrade ruby version to 1.9.3 , but I already have this version.
Thank you
This worked for me yesterday on Win7 using ruby 1.9.2p290. Ruby 1.9.3p194 failed with the same error you are getting.
Remember that the tunnel is a connection between the mysql client running on your local machine to the mysql service on cloudfoundry, so step 1 is making sure that your local mysql works, including your path so that vmc can easily find your client. Refer to the steps at http://docs.cloudfoundry.com/tools/vmc/caldecott.html for details
Can you please execute the following commands and paste the output here?
ruby -v
vmc -v