Bash: Import Command not found error Repl It - python

I've been working on a project in Python using Repl it. I have some experience with programming but I am a beginner to github and right now I am stuck on an error. I tried many different things but don't understand what is causing the error. I need to type a set of commands to instruct the REPL environment to initialize the file directory as a git repository which would allow me to execute git commands within the directory after I finish the initialization. Once I import os in the shell, it gives me an error that bash: import: command not found. I am using Python. I was wondering if anyone had any solutions to help me fix this error. I would really appreciate it.
Error being displayed in Repl IDE Shell

Repl.it's shell is a standard linux shell. Use the python command to open the interactive python prompt.

Related

Configuring Python execution from VS Code

I was trying learning about logging in python for the first time today. i discovered when i tried running my code from VS Code, i received this error message
/bin/sh: 1: python: not found however when i run the code directly from my terminal, i get the expected result. I need help to figure out the reason for the error message when i run the code directly from vscode
I've tried checking the internet for a suitable solution, no fix yet. i will appreciate your responses.
Python Interpreter to be set up. Many ways mentioned in the vs code documentation https://code.visualstudio.com/docs/python/environments, here easiest would be to open command palette and search for python interpreter and there you can enter the path of python/python3 installed.
You can use shortcuts "Ctrl+Shift+P" and type "Python: Select Interperter" to choose the python interpreter.
You can also click the button in the lower right.
The error message you are receiving indicates that the "python" executable is not found in the PATH environment variable of the terminal you are using from within Visual Studio Code.
Add the location of the Python executable to the PATH environment variable in your terminal.
Specify the full path to the Python executable in your Visual Studio Code terminal.
You can find the full path to the Python executable by running the command "which python" in your terminal.

the command "jupyter notebook" refuses to work on my command line on windows

This is the exact error it's showing
The Error:
I've tried adding my python interpreter to my systems path but that isn't working too. Besides before I did that my system already recognized my Python installation's path 👇🏾
Python working well:
Please how do I solve this?
Edit:
Screenshots of the "pip show jupyter" command and the import jupyter; print(jupyter.__file__)
Thanks to #LironBerger for providing the solution which is to use the jupyter_notebook command as shown below 👇🏾

CLI command executes from terminal but not Python

I am using Liquibase (http://www.liquibase.org) to try and diff two databases. Liquibase is installed and running fine from CLI, however when I try to fun the same command from Python 3.7 using subprocess and shlex i can FileNotFoundError: [Errno 2] No such file or directory: 'liquibase': 'liquibase'
When I add subprocess.call('pwd') to Python script, I get the same directory as when I am executing the command from terminal. Liquibase install directory is added to my system path when do I echo $PATH, my understanding is that both the CLI and the Python execution are using the same environment. So I don't understand what is the difference in execution?
UPDATE: this seems to be an issue related to PyCharm. I tried executing from VS Code and there were no errors. I am using PyCharm Professional. Does anyone have an idea of what is wrong with my setting in PyCharm?
PyCharm may be using its own shell and so its PATH environment variable may not contain a path to liquidbase binary. Try this.

Python console not launching properly from command line

I seem to have problem launching python from command line. I tried various things with no success.
Problem: When trying to run python from the command line, there is no response i.e. I do not get message about 'command not found' and console does not launch. Only option to open python console is to run C:\Python34\python.exe directly. Running using python command does not work even when in the python directory but python.exe launches. Issue with the launching this way is that python console is launched in new window. This whole problem is present only on one machine while on my other machine I am able to run python correctly and console launches in the command prompt window from which the python command was executed.
PATH is correctly set to
C:\Python34\;C:\Python34\Scripts;...
and where python correctly returns C:\Python34\python.exe. I verified that running other commands imported through PATH (such as javac) run correctly.
Things I tried:
Completely re-installing python both with x86 and x64 python installations with no success.
Copy installation from my second machine and manually set the path variables - again no success.
Can anyone hint how to resolve this behavior?
(Additional info: Win 8.1 x64, python 3.4.2)
Issue resolved. Since no feasible solution was found in 2 days, I decided to wipe all keys containing 'python' from registry as well as some files that were not parts of other programs. This resolved the issue after re-installing python.
If anyone finds the true cause of this misbehavior and other - less brutal - solution, please write it here for future reference.
Recent Python installer has option to add PATH.
If you didn't use it, you can register directory where python.exe is to PATH environment variable.
But I prefer py launcher. It may be installed via Python 3.3 or 3.4.
With it, you can start Python via py or py -3.4.
See https://docs.python.org/3/using/windows.html#python-launcher-for-windows

Python Shell - Syntax Error

I am very very new to Python. I am trying to get a python program to run by writing 'python hello.py' but every time I do that I get a Syntax Error. Why is that?
However when I open the file and click on run module, it works. Why won't it work if I type 'python hello.py'
Is there anyway I can navigate to the directory where the file is stored and then run it? I tried placing my file in directly in the Python23 folder :P didnt work anyway
Please help me. I have Python 2.3.5
I'm guessing that you're running python hello.py within the Python REPL. This won't work; python hello.py is something that starts Python that you'll need to run in your system shell.
What is the error?
Place python's filepath to the python.exe in your system's PATH, then you can run a python file from anywhere.

Categories

Resources