I'm trying to run shell commands in the Jupyter notebook but it doesn't work
!which python
It shows an error
'which' is not recognized as an internal or external command,
operable program or batch file.
If you are working on windows based system:
!where python
Else:
%%bash
which python
References:
https://www.shellhacks.com/windows-which-equivalent-cmd-powershell/
https://stackoverflow.com/a/48529220/15488129
Can you run python3 --version. I am assuming you are using Windows. Open your command line and run the command too. If you still get the same response, it means you did not add python to path while installing. Did you install using Anaconda?
If you want to add python to path, just simply follow this link. It's self-explanatory. Let me know in the comment section if you still have issues.
https://datatofish.com/add-python-to-windows-path/
Related
I am attempting to follow this tutorial to learn how to use the Cookiecutter folder structure for data science projects. My machine is running Windows 10 and I am using Anaconda.
It seems that the Cookiecutter project structure relies heavily on Makefiles, as does the above tutorial I am trying to follow.
Is there a way to use make on Windows and while using Anaconda?
What I've tried....
The first step is to check my installations. I open Anaconda command prompt and run each of the following.
conda --version
make --version
git --version
cookiecutter --version
When I run make --version I get the following error. 'make' is not recognized as an internal or external command, operable program or batch file.
When I attept to install make by running conda install -c anaconda make, I get:
PackagesNotFoundError: The following packages are not available from current channels:
- make
Looking at the Anaconda make documentation here, I see it is not available for Windows.
More searching led me to m2w64-make, with documentation found here.
I open an Anaconda command window and install the package using conda install -c conda-forge m2w64-make. Installation appears to run with no errors.
However when I attempt to run this package, nothing happens.
When I run m2w64-make --version I get:
'm2w64-make' is not recognized as an internal or external command,
operable program or batch file.
When I run make --version I get:
'make' is not recognized as an internal or external command,
operable program or batch file.
This Stack Overflow post appears to be very similar at first, but all of the answers tell the OP to use Chocolatey, and do not give an option for Anaconda.
Running mingw32-make --version works.
If I want to open a jupyter notebook by command prompt I got below error:
'jupyter' is not recognized as an internal or external command,
operable program or batch file.
And also, I want to use pip commands, I got the same error:
'pip' is not recognized as an internal or external command,
operable program or batch file.
But in anaconda prompt I did not get any error it is run finely. I can open jupyter notebook without any error and also I can run pip without any error to install packages.
What can I do for command prompt to overcome this error?
Anaconda Prompt adds the path to the Anaconda binaries (jupiter, pip, etc.) to the PATH environment variable, so you can run them as commands from the prompt.
To be able to run the commands from the "normal" prompt you can manually add the path to the corresponding binaries to the PATH environment variable. Or choose the corresponding option while installing Anaconda (see Step 8 in the installation instructions).
Note the recommendation in the docs:
We do not recommend adding Anaconda to to the PATH environment variable, since this can interfere with other software. Instead, use Anaconda software by opening Anaconda Navigator or the Anaconda Prompt from the Start Menu.
Just like when you install a pip module in bash you can use it straight away from the Terminal without needing to start python like a system command.
Is there a way to do the same thing in windows command prompt without it showing the error "command not found"?
I am very new to python and plan to use psychopy quite a lot. I am on a work computer but have full admin rights.
Psychopy came with python version 2.7.11 and includes setuptools already.
I am trying to install the selenium module, but having trouble getting pip to work at all.
In cmd, it is recognising the 'python' command, so I know python is in my path.
I get the message "can't open file 'pip': [Errno2] No such file or directory" from:
python pip install selenium
I get " 'pip' is not recognised as an internal or external command" from:
pip install selenium
When I change directory to where pip is located, I get:
Fatal error in launcher: Unable to create process using '"'
Using pip2 makes no difference.
It seems a simple thing but where am I going wrong with this?!
I never really got to the bottom of this, but this is what I found out and here are the commands that worked for me in Windows. Be aware that I am far from expert!
To run python scripts (*.py) from command line (cmd) then C:\PsychoPy2 and C:\PsychoPy2\DLLs need to be in path. ('Path' contains directories or file extensions that can be more globally accessed, i.e. do not require you to change the prompt to the relevant directories first).
To check, open cmd and either type echo %PATH% or just type python. (If python starts, the line will say >>>. You can exit by typing quit())
To add to path, get properties of computer, then advanced system settings, then environment variables.
To check pip.exe (a sort of installation wizard) is installed, either search for the file, or check C:\PsychoPy2\Scripts for it. This may also need to be in path.
To reinstall the latest versions of pip and setup tools, I went to cmd and typed:
python -m pip install -U pip setuptools
If the same code did not work for other modules (which in my case was due to network access), then I downloaded the wheel file (*.whl) for that module (from their website) and ran the following code:
python -m pip install c:/modulename.whl
These may not be the correct ways of doing things, but they worked for me when I couldn't get other ways to work!
I've just had the exact same issue with the pip install, and a conflict with PsychoPy installations. I think it's because python automatically wants to call on the path that's been set by Psychopy, so it can't get to the 'pip' folders that for me, remain in a temporary/hidden file. This wasn't intuitive for me - on any machine without psychopy python just 'works' when you download it.
I don't know what the deal is, but I installed cx_Freeze with pip
pip install cx_Freeze
Pip says that everything is installed into my site-packages folder.
I double checked that cx_Freeze is in the folder and that the folder in on my windows PATH.
But whenever I try to run cxfreeze I get an 'cxfreeze' is not recognized as an internal or external command, operable program or batch file error.
I tried running:
cxfreeze bookit.py --target-dir bookitdir
cx_Freeze bookit.py --target-dir bookitdir
all to no avail. I am not super familiar with windows. I do all my hacking on my macbook, so I'm sorry if this is a dumb question.
Edit: I also confirmed that C:\Python27\Scripts\ is on the path as well. Still no dice.
If python was installed in "C:\Python34\", usually cxfreeze would be installed in "C:\Python34\Scripts". Make sure it was in PATH too.
And cxfreeze.bat should be edited to point to the right exe files.
As the selected answer here just do the following orders:
cd to your python directory and then the Scripts folder, for me it is:
C:\Python27\Scripts
Here just run the following command:
python cxfreeze-postinstall
Now you can use cxfreeze like this:
cxfreeze hello.py --target-dir=your_target_directory
Hint: For 3 DO NOT forget to run cmd as Administrator
I know it's an old question but In Windows 11,
Assuming you've already had the environmental variables set up.
Using Python 3.10
After installing cx_Freeze with pip like this
pip install cx_Freeze
You have to call it like this
cxfreeze <your-python-file>
instead of the usual linux cx_Freeze
This is how windows copy the file, you have to reference it like below, or you could also change the name of the file to the one you normally use in Linux
Now you can enjoy playing Sticky Bubble on Android and relax a bit while it installs and compiles your app :)