Python at Synology, how to get Python3 modules installed and where is Python2.7 installed?

独自空忆成欢 提交于 2019-12-06 04:04:16

I'm not sure you can remove Python 2 altogether, but you can install Python 3 and evoke it specifically instead of Python 2.

First, make sure Python 3 is Installed: Log into your Synology via the web administration and in the 'Package Center' make sure 'Python 3' is installed. (You will find it under 'Developer Tools' within the 'Package Center')

Next, specifically evoke Python 3 by simply calling python3

You could also try using the locate command on your Synology to find the exact location of Python 2. To do this enter the following on your Synology:

ipkg update
ipkg install mlocate

And here is a tutorial on how to use the command: http://www.thegeekstuff.com/2012/03/locate-command-examples/

Good luck!

Also, If you don't have luck on Stack Overflow I'd run over to the Synology Forums for help as well: https://forum.synology.com

  • (1)install python2.7 and python3.5 from DSM packages
  • (2)ssh login & sudo -i
  • (3)run python and run python3, if both work go next.
  • (4)run pip -V should return pip 10.0.1, it is for python2.7
  • (5)run pip3 -V return "command not found", ..because the path is not right.
  • (6)try /volume1/@appstore/py3k/usr/local/bin/pip3 -V,
             if sucess. go next. now you can install module for python3,
             it's different path depends on your system, command for example:
             /volume1/@appstore/py3k/usr/local/bin/pip3 install numpy should be work!
  • (7)for convenient, shorter command is good for use,so go next step:
             sudo vi .profile, (or .bashrc for specific user login)
  • (8)add alias at the end:
             alias pip3='/volume1/@appstore/py3k/usr/local/bin/pip3'
  • (9)source .profile or sudo reboot
  • (10)test pip3 -V, should work for python3.x
  • Wouter

    Ok, many thx for the replies, I solved it with:

    1. Confirmed that Python 2.7.9 is installed by default in Synology DSM 5.2 (and not visible in package center).

    2. I was able to add modules to Python3 by specifically evoking the pip module installation for Python3 using this command:(thx to this Q&A)

      /volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/pip install tweepy

    (installing the tweepy module in this case)

    And FYI the full command overview:

    admin@DiskStation:/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages$ sudo -i
    Password:
    root@DiskStation:~# curl -O https://bootstrap.pypa.io/get-pip.py
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 1488k  100 1488k    0     0  1704k      0 --:--:-- --:--:-- --:--:-- 1703k
    root@DiskStation:~# sudo python3 get-pip.py
    Requirement already up-to-date: pip in /volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages
    root@DiskStation:~# pip install tweepy
    Requirement already satisfied (use --upgrade to upgrade): tweepy in /usr/lib/python2.7/site-packages
    Requirement already satisfied (use --upgrade to upgrade): six>=1.7.3 in /usr/lib/python2.7/site-packages (from tweepy)
    Requirement already satisfied (use --upgrade to upgrade): requests>=2.4.3 in /usr/lib/python2.7/site-packages (from tweepy)
    Requirement already satisfied (use --upgrade to upgrade): requests-oauthlib>=0.4.1 in /usr/lib/python2.7/site-packages (from tweepy)
    Requirement already satisfied (use --upgrade to upgrade): oauthlib>=0.6.2 in /usr/lib/python2.7/site-packages (from requests-oauthlib>=0.4.1->tweepy)
    root@DiskStation:~# python3 ^C
    root@DiskStation:~# python3 /volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/pip install tweepy
    Collecting tweepy
      Using cached tweepy-3.5.0-py2.py3-none-any.whl
    Collecting requests-oauthlib>=0.4.1 (from tweepy)
      Using cached requests_oauthlib-0.6.1-py2.py3-none-any.whl
    Collecting requests>=2.4.3 (from tweepy)
      Using cached requests-2.10.0-py2.py3-none-any.whl
    Collecting six>=1.7.3 (from tweepy)
      Using cached six-1.10.0-py2.py3-none-any.whl
    Collecting oauthlib>=0.6.2 (from requests-oauthlib>=0.4.1->tweepy)
      Using cached oauthlib-1.1.2.tar.gz
    Building wheels for collected packages: oauthlib
      Running setup.py bdist_wheel for oauthlib ... done
      Stored in directory: /root/.cache/pip/wheels/e6/be/43/e4a2ca8cb9c78fbd9b5b14b96cb7a5cc43f36bc11af5dfac5b
    Successfully built oauthlib
    Installing collected packages: requests, oauthlib, requests-oauthlib, six, tweepy
    Successfully installed oauthlib-1.1.2 requests-2.10.0 requests-oauthlib-0.6.1 six-1.10.0 tweepy-3.5.0
    

    (And I uninstalled the SynoCommunity Python3 package again and now use the DSM package center Python3 version)

    易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
    该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!