Python only found in conda prompt - command

I'm using conda in general and was going to check for another project wether I still have python installed. (I'd like to try Instant NGP.) I just realised when I'm in the regular cmd prompt python is not found and I'm automatically redirected to download python. Does this mean anything in terms of python being "availiable" on my pc?
C:\Users\xxx> python
Gets redirected to python download.

Related

Wrong Python interpreter being used by VS Code

I am on Ubuntu 20.04 and have both Python2 and Python3 installed natively. I have also installed Python through miniforge, a variant of miniconda. In VSCode I have both the MS Python extension and Pylance installed.
I use the miniforge python for my coding. This works perfectly fine in PyCharm.
However in VSCode, when I try to execute the same file I get errors. After investigating it seems that VSCode is picking native Python2 - even though I have the miniforge Python selected. In this picture it can be seen that the status bar at the bottom states Python interpreter selected is Python3. But the output window shows that the python interpreter is Python2.
A more confusing thing is when I use VSCode for Jupyter notebook files then it picks up the interpreter correctly and I have no issues.
I have checked both User and Workspace settings, and they all point to Python3. How can I fix this for standard .py files?
I prefer VSCode to PyCharm, but will need to use PyCharm till this is resolved.
It seems that your system console cannot see python3. You need to put the python3 in the PATH variable, before python2. Like:
PATH=path/to/python3:path/to/python2:$PATH
Also, make sure that the environment containing python3 is activated before command prompt appears. It can be done in bash_profile by adding a line like
conda activate my_env_with_python3
Try changing the settings "Python:Python path", "Python:default interpreter path" and "Python:conda path" also.
I have just bumped into something similar. The Run code option resulted in the file being run with the default interpreter instead of the venv-based one with necessary packages installed.
The fix was simply to use "Run python file" instead:
The run-code behavior must be customizable, something is mentioned e.g. here: Run Code vs Run Python File in Terminal for VSCODE but I didn't bother.

Powershell commands/scripts not actually running

I am trying to install Emscripten on my computer, and I have run into trouble getting Emscripten actually installed.
I am using the same commands as can be found on the project webpage, but when I try to run
emsdk install latest
Powershell (which is what I am using, but the basic command prompt is behaving the same way) doesn't do anything at all - it just returns without installing anything.
For reference, I have installed Emscripten on this same computer before, but decided to try and do a fresh install of Emscripten after running emsdk activate latest decided to "stop working" as well (whereas it worked just fine last week) - running the command, Powershell simply returned without actually doing anything.
Any ideas on what to check to see why these commands don't seem to run?
I think I solved it. When running the install command in Powershell ISE, it threw the error "Python was not found but can be installed from the Microsoft Store: https://go.microsoft.com/fwlink?linkID=2082640"
despite me having Python installed. Changing the order of my PATH variables to set my Python install directory above the Winapps directory solved the issue with running the install command.

pylab backend from cmd prompt?

I've run into an issue...
First, I've been trying (with little success yet) of 'packaging' a Canopy python file into an .exe. I'm trying to make a 'simple' way to run our program(s) for our client.
With those issues, I thought I'd make a .cmd file with 'python myprog.py' in it. Well, it fires up my code without having the Canopy environment there to confuse my end-users, BUT, it appears that the PyLab backend isn't Qt4, as the screen appears quite a bit different, and the actual program doesn't quite run the same :(
Is there some way to tell Canopy that when I start a program using 'python xxx.py' that it should be using the Qt4 package? I've looked at the Preferences for Canopy, and both the Notebook tab and the Python tab have the PyLab backend set to Interactive (Qt4)? If I can find that and get my panels to look the same as in the Canopy environment, I'll see if the rest of the program straightens out too.
Steve, if you wish you can hard-code this into your program, but as a quick solution, precede your python call with:
set ETS_TOOLKIT=qt4

Install Ipython notebook without Internet connection

I followed these instructions:
http://ipython.org/install.html
Used last way to install (downloading source and "python setup.py install").
After that, console ipython worked fine, but trying to run notebook gave me error.
I always searched errors in Google and it always was a missing package.
Notebook probably depends on external packages.
After manually installing 2 packages it still gave me error.
Gave up and uninstalled everything (including Python itself).
Is there any way to manually download and install the notebook?
Do you know of any finite number of files/packages I have to download and install so the notebook will run just fine?
Thank you.
As you are using Windows, I suggest you to install Winpython.
It includes all the libraries and tools (e.g. IPython) you will need in the same executable. So you only need to download the desired version and then you can pass that version using a USB stick to the computer without internet.

Using Scrapy with Windows Powershell

I'm unable to use scrapy commands via the Windows Powershell however I can use it via python using execute from scrapy.cmdline.
When I type anything beginning with scrapy, the 'open with' dialogue window pops up asking which program I'd like to use to open the file 'scrapy', which contains the following:
#!C:\Users\User\AppData\Local\Enthought\Canopy32\User\Scripts\python.exe
from scrapy.cmdline import execute
execute()
I've tried:
adding a . ahead of scrapy as suggested here
adding python ahead of commands suggested here
all of the above in cmd instead of PS
When I use scrapy through the Python interpreter everything functions correctly, does anybody have any suggestions as to what I'm doing wrong? Thanks.
I'm using PS version 2.0, Python 2.7.6 on Windows 7.
I'm guessing you have c:\Python27\Scripts\ folder in your PATH environment variable ($env:PATH to find out) - depends on your Python version, of course, it may be in that Enthought Canopy folder path, for instance.
When you type scrapy, Windows is finding the scrapy file (which you don't know exists, and that's why you say "there aren't any files") and trying to run it, but can't because it has no extension.
You are prompted to open it in a program, and you choose a text editor, and see the content (because there is a file). Instead you could choose to open it with Python - e.g. browsing to the C:\Users\User\AppData\Local\Enthought\Canopy32\User\Scripts\python.exe file and choosing that. Or c:\python27\python.exe if you have that.
To fix it without having to choose a file, you need to specify both where the Python interpreter is and where the scrapy file is, e.g.
python scrapy startproject myproject has to become something like
C:\Python27\python.exe C:\Python27\Scripts\scrapy startproject C:\Users\username\Documents\projects\myproject
(You will have to find out where Python.exe and scrapy are on your system. I am deliberately ignoring the Enthought path you show because I don't know anything about how it installs, and what folders it uses).
Edit: I suggest not changing the PATH because it might unintentionally break other things, and instead creating a wrapper for the scrapy launcher:
Rename Scripts\scrapy to Scripts\scrapy-helper
Create a file named Scripts\scrapy.bat with the content
C:\Python27\python.exe c:\Python27\Scripts\scrapy-helper %*
With the correct paths for your system. When you type scrapy at the command prompt, Windows/PowerShell will find it, run it as a batch file, call the right Python to run the right scrapy script, and pass any parameters you used through to Python.