Forum

You are not logged in.

#1 12-07-2017 13:44:32

dharasty
Membre
Registered: 20-11-2011
Posts: 4

Set python3 as default; install public modules

I'd like to use python3 as my default version of python on AlwaysData.

Is there a command I can use to set that?  Or will I always have to type "python3"?

I'd like to then load some public and pure-python modules, such as:
- requests
- dateutils

How can I set up my environment to:
- use pip correctly with python3
- place those modules in my user space
- set python3 to use them (I assume I just set PYTHONPATH in my .bashrc)

Merci,
Dan

Offline

#2 12-07-2017 14:10:22

@Héloïse
Staff
Registered: 03-03-2016
Posts: 196

Re: Set python3 as default; install public modules

Hello,

  • Different versions of Python 3 and Python 2 are available in Environment > Python. The version you put on this menu is the version that is used when you start python. Attention, never use python3, just python (or /usr/bin/python).

  • Use pip:

    $ pip install requests dateutils
  • When you install some modules on your account with pip install they are automatically added to the sys.path by Python.

Offline

#3 12-07-2017 14:58:46

dharasty
Membre
Registered: 20-11-2011
Posts: 4

Re: Set python3 as default; install public modules

Aha! I didn't know about that setting in my admin panel.

I was able to install requests with:

  pip install requests

However when I did

  pip install dateutil

I would get this error:

Could not find a version that satisfies the requirement dateutil (from versions: )
No matching distribution found for dateutil

So I got the URL for the whl from PyPI, then downloaded the whl directly with wget:

wget https://pypi.python.org/packages/4b/0d/7ed381ab4fe80b8ebf34411d14f253e1cf3e56e2820ffa1d8844b23859a2/python_dateutil-2.6.1-py2.py3-none-any.whl#md5=342c025339de1e7c2138c74983c111d7

Then used pip to install the whl file:

pip install python_dateutil-2.6.1-py2.py3-none-any.whl

Merci beaucoup!

Offline

#4 12-07-2017 15:14:37

@Héloïse
Staff
Registered: 03-03-2016
Posts: 196

Re: Set python3 as default; install public modules

Yes sorry for the mistake for dateutil, it would be:

$ pip install python-dateutil 

Offline

#5 12-07-2017 16:34:23

dharasty
Membre
Registered: 20-11-2011
Posts: 4

Re: Set python3 as default; install public modules

Thank you again, @Héloïse.

Last edited by dharasty (12-07-2017 16:34:44)

Offline

Board footer

Powered by FluxBB