1

I have a Python library which includes some scripts that are installed during setup (python setup.py install). I've installed the library in a Conda environment.

The script is installed using the script key in my setup.py:

setup(
    ... 
    scripts=['scripts/my_app'],
)

When I active my Conda environment with the package installed, I expect to be able to call it from the command line (ie its in my PATH). On Linux and Mac there's no problem with this.

On Windows, the script is added to the system path, but if I run it in Powershell (my_app), it launches a request to open the file which contains:

#!C:\Users\Me\AppData\Local\conda\conda\envs\my_env\python.exe
# EASY-INSTALL-SCRIPT: 'my_package==0.0.1','my_app'
__requires__ = 'my_package==0.0.1'
__import__('pkg_resources').run_script('my_package==0.0.1', 'my_app')

In an Anaconda (DOS) prompt, it doesn't work at all (not recognised). The code runs fine if I call the program from the library folder (e.g. python ./scripts/my_app).

The conda env is otherwise fine, I can import the package within an interpreter or other python script. So python is definitely in my path, and it's the correct python.

Is there some additional setup required for Windows? It seems like it's finding the wrapper around the script, but it's not executing it as a python file.

(This may be a duplicate question, but it's quite hard to search for!)

Josh
  • 2,658
  • 31
  • 36
  • "my_env" should have a pip as well..rather than manually installing using setup.py can you try running: python -m pip install my_app – behold Apr 25 '19 at 12:21
  • if you don't have a tarball, then you may move to the dir containing setup.py and then run: pip install -e . – behold Apr 25 '19 at 12:22
  • @behold That doesn't seem to be the problem. The package installs fine, but calling the installed script just opens the file, it's not run with Python. – Josh Apr 25 '19 at 12:53
  • ok..is python.exe appended to the PATH and PYTHONPATH system variable?https://stackoverflow.com/questions/13596505/python-not-working-in-command-prompt – behold Apr 25 '19 at 13:21
  • if so, make sure that python scripts default program is set to python; https://stackoverflow.com/questions/15121714/how-do-i-get-a-python-program-to-run-instead-of-opening-in-notepad – behold Apr 25 '19 at 13:23
  • @behold Yes, all this happens when I activate the Conda environment. You can see in the generated script that it contains a path to the right executable. The problem is that script is either generated incorrectly for Windows, or it's not opened correctly. – Josh Apr 26 '19 at 05:56

0 Answers0