# Running from source * `stable` is now targeted against Python 3.11, and will no longer work under Python 3.8 or earlier (Ref: [TypeError when running from source on stable branch #1497](https://github.com/EDCD/EDMarketConnector/issues/1497)) * `main` is now targeted against Python 3.11, and will no longer work under Python 3.8 or earlier (Ref: [TypeError when running from source on stable branch #1497](https://github.com/EDCD/EDMarketConnector/issues/1497)) * `develop` is targeted at Python 3.11 and has no guarantee about working on earlier Python versions. **If you are not actively developing the application then you SHOULD NOT BE RUNNING THIS BRANCH.** In general you can check the contents of the file `.python-version` in the source for the version that code is targeting. This file is *not* included in the Windows installers/packages as it's not necessary. ## Ensure Python is installed On Windows or macOS Download and install an appropriate version of CPython ('Core Python') from [python.org](https://python.org). **You need a 32-bit version on Windows as this application has some code that calls OS APIs that needs changing for 64-bit and we've not yet had the incentive to resolve this.** On macOS you might run into issues with the HomeBrew python, to do with a broken `tk`. See [#670 Update requirements.txt for MacOS](https://github.com/EDCD/EDMarketConnector/issues/670) for discussion about this. That might be fixed now, but if you're having issues with a HomeBrew version of Python the first thing we'll ask you to do is try again with the python.org version. On Linux you should use your distribution's Python 3.x packages, so long as they provide at least 3.10.x. Note that you might need to specify `python3` or `pip3` in any comments below, rather than `python` or `pip`. We have moved to Python 3.11 and if you find that your Linux distribution is still only shipping Python 3.8 or earlier you will **HAVE** to install a later version separately and ensure you are using the correct version. ### Using a non-distribution Python on, e.g. Debian One tested method to get a later Python on Debian 11.x is to utilise [pyenv](https://github.com/pyenv/pyenv-installer/). 1. You will need some pre-requisites: apt install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \ libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev \ libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev 1. Choose where you want `pyenv-installer` to live, e.g. /usr/local/src: $ mkdir -p /usr/local/src $ cd /usr/local/src $ curl -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer -o pyenv-installer 1. Choose where you want `pyenv` itself to live, make the directory, and then run pyenv-installer with PYENV_ROOT pointing there, e.g.: $ mkdir -p /usr/local/src/pyenv $ PYENV_ROOT=/usr/local/src/pyenv ./pyenv-installer 1. Choose where the actual extra versions of Python will live, e.g. /usr/local/pyenv: $ mkdir /usr/local/pyenv 1. Add pyenv to your shell startup, e.g. `~/.bashrc`: export PATH="/usr/local/src/pyenv/bin:$PATH" export PYENV_ROOT=/usr/local/pyenv eval "$(pyenv init -)" eval "$(pyenv virtualenv-init -)" You will either need to start a new shell now, or issue the commands above in the current one (as well as adding them to shell startup). 1. Use `pyenv` to install a new version of Python: pyenv install 3.11.1 1. Check that version is now available: $ pyenv versions 3.11.1 1. Activate that version and ensure shell is set up for it: $ pyenv local 3.11.1 # You could use 'global' as well here $ eval "$(pyenv init -)" # Sets it in PATH $ which python /usr/local/pyenv/shims/python $ python --version Python 3.11.1 1. Ensure `pip` is installed and up to date for this version: $ python -m pip install pip $ python -m pip install --upgrade pip 1. If you want a 'venv' for just EDMarketConnector then you now: **This step is mandatory on Debian with Bookworm (12.x) or Later, or any system which enforces Externally-Managed Environments.** _For information about Externally Managed Environments, see [This Python Documentation Page](https://packaging.python.org/en/latest/specifications/externally-managed-environments/#externally-managed-environments) or [This PEP Document](https://peps.python.org/pep-0668/)_ $ cd $ python -m venv venv $ source venv/bin/activate $ which python /venv/bin/python Now you will need to remember `source venv/bin/python` before running `./EDMarketConnector.py`. If you want to go back to using the prior version of Python then just issue the command: $ deactivate # This is an alias added by 'activate' $ which python /usr/local/pyenv/shims/python # or whatever the python was before ## Ensure you have working `pip` Ensure you both have `pip` installed, and that it is for Python 3.x by running: pip --version The output will have "(python X.Y)" on the end, indicating the version of Python it is for. If this says "2.7", or indeed anything other than "3.X" for some value of "X" then try: pip3 --version On Debian and derivaties you will need the following command in order to install this: sudo apt install python3-pip Otherwise see [Installing pip](https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/#installing-pip). Remember which of `pip` or `pip3` is the correct command for your system when you get to [Use `pip` to install application requirements](#use-pip-to-install-application-requirements) below. ## Ensure you have dependencies installed ### tkinter python.org packages include this. On Debian, Ubuntu, and other Debian derivatives the package you need to install is `python3-tk`: sudo apt install python3-tk On Arch you need: sudo pacman -S tk For other Linux distributions you will need to find the requisite package and how to install it. Keep in mind you need 'tkinter' for 'python3'. Installing 'tkinter' for Python 2.7 won't help you. ### Others All other dependencies will be handled by `pip` below. ## Obtain a copy of the application source Choose one of the following: 1. Using a zip of the latest stable source. Download and extract the [latest stable source code](https://github.com/EDCD/EDMarketConnector/archive/stable.zip). **NB: Some niche functionality will not work without two files from the [FDevIDs repository](https://github.com/EDCD/FDevIDs), which are included in the Windows installer builds.** You specifically need: 1. [commodity.csv](https://github.com/EDCD/FDevIDs/raw/master/commodity.csv) 2. [rare_commodity.csv](https://github.com/EDCD/FDevIDs/raw/master/rare_commodity.csv) which should be placed in `FDevIDs/` that unzipping the release archive will have created. Without these the "Settings" > "Output" > "Market data in CSV format file" feature will not work. 1. OR Clone and checkout the source using git: 1. `cd ` 2. `git clone https://github.com/EDCD/EDMarketConnector.git` 3. `cd EDMarketConnector` 4. `git checkout stable` 5. `git submodule init` # Necessary to populate `FDevIDs/` 6. `git submodule update --checkout` # Necessary to populate `FDevIDs/` As per [Contributing.md](https://github.com/EDCD/EDMarketConnector/blob/main/Contributing.md#git-branch-structure-and-tag-conventions) `stable` will contain the latest released code, or possibly some extra commits leading up to the next release. If you're feeling slightly braver you could use the [main branch source code](https://github.com/EDCD/EDMarketConnector/archive/main.zip) (or `git checkout main`) instead which might contain newer code that we consider stable enough for the next release. **NB: Do not use the `master` branch**, it's almost empty! The name is deprecated and we use `main` instead. ## Use `pip` to install application requirements 1. Ensure additional necessary Python modules are installed with `pip install -r requirements.txt` * Note that on Debian (at least up to and including 10.x aka 'Buster') you'll need `pip3 install -r requirements.txt` * If you get 'command not found' or similar for the 'pip' command then try: `python -m pip --user install pip` ## Provide access to live Journal files The main application doesn't work without access to Journal files. It can't even determine your Commander name without them. So, if you're running this application on a machine separate from where you play the Game you will need to set up a network share of those files. You'll always find them on Windows at: shell:SavedGames\Frontier Developments\Elite Dangerous\ so share that folder. Then get that mounted on the remote machine. Then you will need to set the correct location on the remote machine in the application's `Settings` > `Configuration` > `E:D journal file location` option. ## Ensure log files can be written The [application logfiles](Troubleshooting.md#debug-log-files) are written under `$TMPDIR` if that is set, else whatever the default is for your OS, e.g. `/tmp` on Linux. If you only ever run this application as one user then the default isn't a problem. However, if you do run it as more than one user then the subsequent user(s) won't have permission to write to the log files/directories. The best workaround for this is to ensure you explicitly set `TMPDIR` to a per-user location, e.g. in `~/.bashrc`: ```bash export TMPDIR="${HOME}/tmp" mkdir -p "${TMPDIR}" ``` ## Run the application * Linux: `python3 EDMarketConnector.py` * Mac: `python3 EDMarketConnector.py` * Windows: `EDMarketConnector.py` #Command-line The command-line program `EDMC.py` writes the current system and station (if docked) to stdout and optionally writes player status, ship locations, ship loadout and/or station data to file. This program requires that the user has performed Frontier Authentication through the main application. Arguments: ``` -h, --help show this help message and exit -v, --version print program version and exit -a FILE write ship loadout to FILE in Companion API json format -e FILE write ship loadout to FILE in E:D Shipyard plain text format -l FILE write ship locations to FILE in CSV format -m FILE write station commodity market data to FILE in CSV format -o FILE write station outfitting data to FILE in CSV format -s FILE write station shipyard data to FILE in CSV format -t FILE write player status to FILE in CSV format -d FILE write raw JSON data to FILE -n send data to EDDN -p CMDR Returns data from the specified player account ``` The program returns one of the following exit codes. Further information may be written to stderr.
  1. Success. Note that this doesn't necessarily mean that any requested output files have been produced - for example if the current station doesn't support the facilities for which data was requested.
  2. Server is down.
  3. Invalid Credentials.
  4. Verification Required.
  5. Server is lagging.
  6. I/O or other OS error.