Using Scrapy with Windows Powershell - 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.

Related

How do I change the path of pylint in coc.nvim?

I am using the CoC extension in Neovim. When I import some python modules I have installed, pylint shows an error, as if they were not installed, even though they are. I know this because the file executes correctly (and I installed them previously). After doing :CocCommand workspace.showOutput Pyright, I get the path of the version of python being used, and of course it is not the one I want. But I don't know how to change it.
Two ways:
activate the correct Python used in your project, make sure which python points to the correct path, launch nvim
set the path in coc-settings.json by python.pythonPath, default is python that use from $PATH.

Running a Python file on command prompt launches vscode instead

I'm trying to launch a python script on windows command prompt, but instead of it doing it, it opens the script on vscode instead. I searched the options in vscode and didn't find anything. How can I stop this behavior?
SOLVED
I simply changed the default program for .py files
You need to change the default application for .py files to python.exe.
This will instruct Windows to pass the filename of the python script you're trying to open to python.exe, which will execute it.
python my_script.py
As a bonus, if you change the PATHEXT environment variable to include .py extension. This will allow you to run a python script without prefixing it with python command when working in a shell.
./my_script.py
Python installer does this by default, but if it isn't there, you can add it.

How is the PATH variable defined for the vscode process itself (not the integrated terminal)?

I'm currently using a vscode over a remote ssh connection and cannot figure out how to set the search PATH for the vscode process itself. I have set the PATH for processes run in the terminal in my .bashrc file, which is also sourced from .bash_profile.
In spite of this, vscode complains that pipenv is not on the path although it is visible to my integrated terminal session. In my .bashrc I am loading environment modules to load versions of needed libraries, which get put on the PATH. Since I created my virtualenv using pipenv in the terminal, it knows which python version to use and makes a link to it in the environment definition. Because of the way python virtual environments work, the actual python binary is copied to the virtual environment. And because vscode has hardcoded paths where to look for virtual environments it is able to find the correct version of python that is in use (despite it not seeing it in the PATH).
In addition, hardcoding the path to pipenv using the extension setting python.pipenvPath still produces a "not found" error.
Solutions that I have seen elsewhere suggest launching vscode from the command line so that the process inherits the PATH settings. However, this will not work over a remote connection.

SML/NJ Error in Command Prompt

So I installed SML/NJ in Windows 10 using the Windows Installer Package "smlnj-110.79", and following the instructions in this coursera video lecture, i should be able to open the command prompt and access sml by typing "sml". However, when I return "sml" I'm prompted that "sml is not recognized as an internal or external command, operable program or batch file". I should note that it works fine if I open the actual SML/NJ program itself. I am trying to use SML/NJ within emacs, will this affect that? Thank you!
You need to add the directory containing SML to your system path. On my machine the path entry is C:\Program Files (x86)\SMLNJ\bin\. See this for modifying the path in Windows 10. If you haven't manually edited your path before (which seems to be the case given the question) you do need to be careful to add to rather than overwrite the current path. Windows has always been clunky in making this possible. This is an article that suggests some utilities. I haven't tried them, so I can't vouch for them.

Can't get eclipse to run terminal command on mac

I have installed swig on my mac and it works in the console just fine. If I type swig -verison in terminal it spits out the version. Eclipse keeps telling me that it can't find swig. I am using the liquidfun library http://google.github.io/liquidfun/SWIG/html/index.html and it told me to put this export SWIG_BIN=$("which" swig) in .bashrc, which I did. This enviroment variable registers through terminal as well. Eclipse STILL won't grab swig properly. What the hell?
Bash reads .bash_profile, .bash_login or .profile. I don't expect the Eclipse process to load such a file (although I could be wrong) nor the SWIG_BIN variable to augment its search path for executables, but if you launch Eclipse from the shell, it should inherit the shell's environment variables.
Try running swig from eclipse using a full absolute path (the one that "which" returns).
The eclipse.ini file can set some startup parameters but perhaps not the path. There might be other eclipse startup files.
Another possibility is to add swig's directory to the path in a login script. (To test that, log out and back in, then start eclipse.)