petergardfjall / garminexport

Garmin Connect activity exporter and backup tool
Apache License 2.0
507 stars 83 forks source link

Installing GarminExport in a FreeNAS jail #9

Closed JeanDiv14 closed 8 years ago

JeanDiv14 commented 8 years ago

Hi Peter

I accidentally nuked my GarminExport jail in FreeNAS the other day, and I'm struggling to get it going again. I was hoping that you could help, and apologies in advance - I'm a bit of a noob when it comes to Virtual Environments, etc.

So following the instructions in the README.MD, all goes well - I install pip, python2.7 and virtualenv. I successfully complete the first pip command (virtualenv venv.garminexport), but the second fails (.: Command not found.). If I drop the '.' I get an error 'venv.garminexport/bin/activate: Permission denied.'. I went and chmod +x'ed the 'activate' file, and then I get an error that reads 'Badly placed ()'s.'. So I'm at the end of my road there.

The old way that I had it working was to replace the top line of the 'garminbackup.py' file with the python2.7 location, and it had worked for me. Now executing this, I get errors saying that it cant find, as below.

Traceback (most recent call last): File "/garminexport/./garminbackup.py", line 10, in from garminexport.garminclient import GarminClient File "/garminexport/garminexport/garminclient.py", line 10, in import requests ImportError: No module named requests Traceback (most recent call last): File "/garminexport/./garminbackup.py", line 10, in from garminexport.garminclient import GarminClient File "/garminexport/garminexport/garminclient.py", line 10, in import requests ImportError: No module named requests

I'm out of ideas, and sure that I'm doing something silly. Can you please assist?

Ta, Jean

petergardfjall commented 8 years ago

Hej Jean!

Although I'm not familiar with FreeNAS I'll do what I can to help.

It appears to be the case that you cannot source the file venv.garminexport/bin/activate. The '.' or "dot command" is a feature of the bash shell (one of the most common command-line shells in *nix distributions). It is exactly the same command as 'source', so you could try running

source venv.garminexport/bin/activate

instead. If that doesn't work either, I'm assuming that you're running a different shell. Running echo $SHELL should show you what shell you're running on most unix/linux distributions. In my case it outputs "/bin/bash". Maybe that could give some hint.

It may be the case that C shell (csh) is the default shell under FreeNAS. If so, you might try sourcing the csh file:

source venv.garminexport/bin/activate.csh

It is also not strictly necessary to run the garminexport tool in its own isolated virtual environment. A virtual environment is mostly useful to not pollute the global python installation with libraries of different (incompatible) versions. So you might as well try to install the dependencies system-wide. That would typically be done (as root) with

sudo pip install -r requirements.txt

Note that this would be done without the need to create (and activate) a virtual environment.

Hope this can guide you in the right direction!

best regards, Peter

On Mon, Oct 31, 2016 at 5:39 PM, JeanDiv14 notifications@github.com wrote:

Hi Peter

I accidentally nuked my GarminExport jail in FreeNAS the other day, and I'm struggling to get it going again. I was hoping that you could help, and apologies in advance - I'm a bit of a noob when it comes to Virtual Environments, etc.

So following the instructions in the README.MD, all goes well - I install pip, python2.7 and virtualenv. I successfully complete the first pip command (virtualenv venv.garminexport), but the second fails (.: Command not found.). If I drop the '.' I get an error 'venv.garminexport/bin/activate: Permission denied.'. I went and chmod +x'ed the 'activate' file, and then I get an error that reads 'Badly placed ()'s.'. So I'm at the end of my road there.

The old way that I had it working was to replace the top line of the 'garminbackup.py' file with the python2.7 location, and it had worked for me. Now executing this, I get errors saying that it cant find, as below.

Traceback (most recent call last): File "/garminexport/./garminbackup.py", line 10, in from garminexport.garminclient import GarminClient File "/garminexport/garminexport/garminclient.py", line 10, in import requests ImportError: No module named requests Traceback (most recent call last): File "/garminexport/./garminbackup.py", line 10, in from garminexport.garminclient import GarminClient File "/garminexport/garminexport/garminclient.py", line 10, in import requests ImportError: No module named requests

I'm out of ideas, and sure that I'm doing something silly. Can you please assist?

Ta, Jean

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/petergardfjall/garminexport/issues/9, or mute the thread https://github.com/notifications/unsubscribe-auth/ABWoY13lbf3xts7Q3tjvfo1znXbMnE5gks5q5hnGgaJpZM4KlOeN .

JeanDiv14 commented 8 years ago

Hey Peter

Thanks for getting back to me.. Speedy turnaround!

So yes, I'm using the csh shell, and the 'source' command worked. I then get caught when I try to run the 'pip install -r requirements.txt' command. Output is:

Collecting requirements.txt Could not find a version that satisfies the requirement requirements.txt (from versions: ) No matching distribution found for requirements.txt

Same output when trying to run the command outside of the virtual environment.

I'm not really fussy about polluting python libraries as it a single purpose jail.. so long as it can run your script on a cronjob and pull the files to a mounted volume (that then gets served up with a separate btsync jail across my devices), I'm happy and keep my other jails clean. Dunno if this makes an easier workaround possible..?

Thanks again. Jean

petergardfjall commented 8 years ago

Could it be that you forgot the -r switch?

That is, try with pip install -r requirements.txt.

I get the same error as you if i run without the -r flag.

JeanDiv14 commented 8 years ago

Yes! That was it.. so now Pip installed the requirements in the Virtual Env (I'm trying to stick to the script), and all went well. Furthermore, SUCCESS when running the script in the Virtual Env. Stoked! Thank you.

It does not work from outside the Virtual Environment however. If I want to run the script in a cronjob, would I make a script that says:

source venv.garminexport/bin/activate.csh ./garminbackup.py -switches, etc deactivate

..?

petergardfjall commented 8 years ago

That sounds just about right. You can skip the deactivate step.

Den 31 okt 2016 19:48 skrev "JeanDiv14" notifications@github.com:

Yes! That was it.. so now Pip installed the requirements in the Virtual Env (I'm trying to stick to the script), and all went well. Furthermore, SUCCESS when running the script in the Virtual Env. Stoked! Thank you.

It does not work from outside the Virtual Environment however. If I want to run the script in a cronjob, would I make a script that says:

source venv.garminexport/bin/activate.csh ./garminbackup.py -switches, etc deactivate

..?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/petergardfjall/garminexport/issues/9#issuecomment-257384433, or mute the thread https://github.com/notifications/unsubscribe-auth/ABWoY5z1ab9yvoywqYNyDlsDBvVQ8p5Kks5q5jgHgaJpZM4KlOeN .

petergardfjall commented 8 years ago

If you plan on running it as a cron job you might want to specify absolute paths.

Den 31 okt 2016 20:01 skrev "Peter Gardfjäll" < peter.gardfjall.work@gmail.com>:

That sounds just about right. You can skip the deactivate step.

Den 31 okt 2016 19:48 skrev "JeanDiv14" notifications@github.com:

Yes! That was it.. so now Pip installed the requirements in the Virtual Env (I'm trying to stick to the script), and all went well. Furthermore, SUCCESS when running the script in the Virtual Env. Stoked! Thank you.

It does not work from outside the Virtual Environment however. If I want to run the script in a cronjob, would I make a script that says:

source venv.garminexport/bin/activate.csh ./garminbackup.py -switches, etc deactivate

..?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/petergardfjall/garminexport/issues/9#issuecomment-257384433, or mute the thread https://github.com/notifications/unsubscribe-auth/ABWoY5z1ab9yvoywqYNyDlsDBvVQ8p5Kks5q5jgHgaJpZM4KlOeN .

JeanDiv14 commented 8 years ago

Cool. Thank you, issue closed :-)