Python at Synology, how to get Python3 modules installed and where is Python2.7 installed?
您能否告诉我如何在Synology上运行模块(DS214play,DSM 6.0.1-7393 Update 1)来获取Python3?
我想要的是:在Synology上的Python3中运行Tweepy和其他模块。
我被困在哪里:
如何获取PIP3以安装Tweepy,如果我尝试得到:
显然我安装了Python 2.7,但我不知道...
1 2 3 4 5 6 | root@DiskStation:/volume1/@appstore/python3/include# ls get-pip.py python3.4m root@DiskStation:/volume1/@appstore/python3/include# python3 get-pip.py -ash: python3: command not found root@DiskStation:/volume1/@appstore/python3/include# python get-pip.py Requirement already up-to-date: pip in /usr/lib/python2.7/site-packages |
因此,要使PIP3正常工作,我需要了解Python2.7的安装位置,甚至可能要删除它(如果需要)。
而且最好知道哪个Python3软件包最适合使用(Synology DSM软件包管理器或SynoCommunity Python3 pacakge中的默认设置)
因为当通过SSH(使用PuTTY)连接到Synology时,我可以在DSM软件包管理器和相关文件夹中看到Python3。
但是我没有看到Python2.7的任何软件包(我相信必须存在该软件包),并且即使与SSH连接时也找不到任何Python 2.7文件夹,即使我很难暗示我必须有一个/ usr / lib / python2。 7 / site-packages"文件夹在某处...
-> Synology DSM软件包管理器的默认Python3在py3k文件夹中:
1 2 | admin@DiskStation: /volume1/@appstore/py3k/usr/local/bin$ python3 |
-> SynoCommunity Python3软件包安装在其他位置:
1 2 3 4 5 6 7 8 9 10 | admin@DiskStation: /volume1/@appstore/python3$ ls bin etc include install.log lib openssl.cnf share admin@DiskStation: /volume1/@appstore/python3/bin$ ls 2to3 busybox bzfgrep bzmore delgroup fatattr infocmp lzmainfo pip3 python3.4 reset start-stop-daemon tset virtualenv-3.4 xz 2to3-3.4 bzcat bzgrep captoinfo deluser gpg-error infotocap mpicalc pip3.4 python3.4m shuf tabs unlink wheel xzcat addgroup bzcmp bzip2 clear dumpsexp hmac256 lzcat nice pydoc3 pyvenv speexdec tic unlzma xmlcatalog xzdec adduser bzdiff bzip2recover c_rehash easy_install idle3 lzma openssl pydoc3.4 pyvenv-3.4 speexenc toe unxz xmllint bunzip2 bzegrep bzless curl easy_install-3.4 idle3.4 lzmadec pip python3 renice sqlite3 tput virtualenv xsltproc admin@DiskStation:/volume1/@appstore/python3/bin$ python3 -sh: python3: command not found |
我做了什么:
我使用Synology DSM软件包管理器安装了Python3,然后通过SSH(使用PuTTY)连接到Synology并设置PATH,并使用PIP来安装Tweepy和其他模块。
我相信它是通过一些命令来完成的,例如:(不幸的是,大多数情况下,复制粘贴操作时并不清楚确切的含义……)
1 2 3 4 5 6 7 8 9 10 11 12 13 | root@DiskStation:~# curl -k https://bootstrap.pypa.io/get-pip.py | python % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 1488k 100 1488k 0 0 1577k 0 --:--:-- --:--:-- --:--:-- 1577k Collecting pip Using cached pip-8.1.2-py2.py3-none-any.whl Collecting setuptools Downloading setuptools-23.1.0-py2.py3-none-any.whl (435kB) 100% |████████████████████████████████| 440kB 551kB/s Collecting wheel Using cached wheel-0.29.0-py2.py3-none-any.whl Installing collected packages: pip, setuptools, wheel Successfully installed pip-8.1.2 setuptools-23.1.0 wheel-0.29.0 |
我能够基于此运行脚本,并感到非常高兴。在出现一些(Unicode)错误之前,从错误日志中看到它是在Synology上运行的2.7版本的Python。看来这些Unicode问题已在Python3中解决了(我在PC上也有),所以我也希望Synology上也有Python3。
确实安装了2.7版本,如果我使用SSH连接并键入Python,则会得到:
1 2 3 4 | admin@DiskStation:~$ python Python 2.7.11 (default, May 13 2016, 05:16:12) [GCC 4.9.3 20150311 (prerelease)] on linux2 Type"help","copyright","credits" or"license" for more information. |
这很奇怪,因为我没有在软件包管理器中的Synology上看到任何Python 2.7软件包,所以我必须通过一些我仅打算用于PIP的SSH命令安装了2.7。
我在Synology上安装了默认的Python3软件包,并且如果键入
我确实准备好使用python3了。
在/ volume1 / @ appstore / py3k /中,我看到了各种Python和PIP版本,并且python3运作良好。但是没有任何模块并且PIP3不起作用("找不到命令"),我从所有可能的目录中尝试了它,并按照类似问答中的建议以各种格式尝试了它。
因此,现在使用DSM软件包管理器,我已经卸载了Python3并安装了SynoCommunity Python3(如Synology论坛上的建议),该目录显示了不同的目录结构。但是似乎更糟,因为现在我看不到对Python 2.7的引用了(但是它仍然可以运行,因此必须存在),甚至无法启动python3:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | admin@DiskStation:~$ cd /volume1 admin@DiskStation:/volume1$ cd @appstore admin@DiskStation:/volume1/@appstore$ cd python3 admin@DiskStation:/volume1/@appstore/python3$ ls bin etc include install.log lib openssl.cnf share admin@DiskStation:/volume1/@appstore/python3$ cd bin admin@DiskStation:/volume1/@appstore/python3/bin$ ls 2to3 bzcmp bzless deluser idle3 lzmainfo pydoc3 renice tabs unxz xz 2to3-3.4 bzdiff bzmore dumpsexp idle3.4 mpicalc pydoc3.4 reset tic virtualenv xzcat addgroup bzegrep captoinfo easy_install infocmp nice python3 shuf toe virtualenv-3.4 xzdec adduser bzfgrep clear easy_install-3.4 infotocap openssl python3.4 speexdec tput wheel bunzip2 bzgrep c_rehash fatattr lzcat pip python3.4m speexenc tset xmlcatalog busybox bzip2 curl gpg-error lzma pip3 pyvenv sqlite3 unlink xmllint bzcat bzip2recover delgroup hmac256 lzmadec pip3.4 pyvenv-3.4 start-stop-daemon unlzma xsltproc admin@DiskStation:/volume1/@appstore/python3/bin$ python3 -sh: python3: command not found admin@DiskStation:/volume1/@appstore/python3/bin$ python Python 2.7.11 (default, May 13 2016, 05:16:12) [GCC 4.9.3 20150311 (prerelease)] on linux2 Type"help","copyright","credits" or"license" for more information. >>> |
所以我到达了要点,要求一些技巧,提示和建议。
如果成功。接下来。现在您可以安装适用于python3的模块,其不同路径取决于您的系统,例如命令:/ volume1 / @ appstore / py3k / usr / local / bin / pip3 install numpy应该可以!
sudo vi .profile,(或.bashrc用于特定用户登录)
别名pip3 ='/ volume1 / @ appstore / py3k / usr / local / bin / pip3'
好的,很多答复,我用以下方法解决了:
确认默认情况下,Synology DSM 5.2中已安装Python 2.7.9(在包中心中不可见)。
通过使用以下命令专门为Python3安装pip模块,我能够向Python3添加模块:(此问与答)
/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/pip install tweepy
(在这种情况下,安装tweepy模块)
并提供完整的命令概述:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | 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 |
(并且我再次卸载了SynoCommunity Python3软件包,现在使用DSM软件包中心的Python3版本)
我不确定您是否可以完全删除Python 2,但是可以安装Python 3并专门调用它,而不是Python 2。
首先,确保已安装Python 3:
通过网络管理登录到Synology,并在"包装中心"中确保已安装" Python 3"。 (您可以在"包装中心"的"开发人员工具"下找到它)
接下来,只需调用
您也可以尝试在Synology上使用locate命令来找到Python 2的确切位置。为此,请在Synology上输入以下内容:
1 2 | ipkg update ipkg install mlocate |
以下是有关如何使用命令的教程:http://www.thegeekstuff.com/2012/03/locate-command-examples/
祝好运!
也,
如果您在堆栈溢出方面没有运气,我也会跑到Synology论坛寻求帮助:https://forum.synology.com