DEV Community

RobbiNespu
RobbiNespu

Posted on • Originally published at robbinespu.gitlab.io on

Setup python 3.6 enviroment with virtualenv

My wife ask me to convert few of PDF files to Excell spreadsheet. I did same thing last year by creating some small scripting program in python to do the conversion, but I don’t know where I put my code right now. Maybe lost during formating my laptop last year..haha 😜

I am ζ‡’ right now (guess what I wrote in hΓ nzΓ¬) and I don’t remember how I did last time. Hahaha.. With my Google-fu skill, I found out DfTables offer free API for converting document to another format. Nice! 😬

Fedora 30 comes with python 3.7 installed. Sadly, dftables.com API doesn’t currently work on 3.7 😲 but no worries since we can create virtualenv to load Python 3.6

Now let install the virtualenv into our workstation, take note I don’t use sudo since my account have administration access, so load with --user args should be enough. I don’t like run something and everthing with sudo.

$ pip3 install --user virtualenv

Download python 3.6 with DNF

$ sudo dnf install python36

Create some directory and cd to that directory. For example I am using ~/workstation/PDF-to-Excell. We will use python 3.6 to install the new python environment:

$ cd ~/workstation/PDF-to-Excell
$ virtualenv --python=/usr/bin/python3.6 python36

now step into the environment using

$ source python36/bin/activate

you should get something like this:

(python36) [rnm@robbinespu PDF-to-Excell] $ python --version
Python 3.6.9

Now let try install DfTables pips

(python36) [rnm@robbinespu PDF-to-Excell] $ pip install git+https://github.com/pdftables/python-pdftables-api.git
Collecting git+https://github.com/pdftables/python-pdftables-api.git
  Cloning https://github.com/pdftables/python-pdftables-api.git to /tmp/pip-req-build-yg3u92jx
  Running command git clone -q https://github.com/pdftables/python-pdftables-api.git /tmp/pip-req-build-yg3u92jx
Collecting requests (from pdftables-api==1.1.0)
  Downloading https://files.pythonhosted.org/packages/51/bd/23c926cd341ea6b7dd0b2a00aba99ae0f828be89d72b2190f27c11d4b7fb/requests-2.22.0-py2.py3-none-any.whl (57kB)
     |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 61kB 682kB/s 
Collecting certifi>=2017.4.17 (from requests->pdftables-api==1.1.0)
  Downloading https://files.pythonhosted.org/packages/69/1b/b853c7a9d4f6a6d00749e94eb6f3a041e342a885b87340b79c1ef73e3a78/certifi-2019.6.16-py2.py3-none-any.whl (157kB)
     |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 163kB 2.1MB/s 
Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 (from requests->pdftables-api==1.1.0)
  Downloading https://files.pythonhosted.org/packages/e6/60/247f23a7121ae632d62811ba7f273d0e58972d75e58a94d329d51550a47d/urllib3-1.25.3-py2.py3-none-any.whl (150kB)
     |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 153kB 10.6MB/s 
Collecting idna<2.9,>=2.5 (from requests->pdftables-api==1.1.0)
  Downloading https://files.pythonhosted.org/packages/14/2c/cd551d81dbe15200be1cf41cd03869a46fe7226e7450af7a6545bfc474c9/idna-2.8-py2.py3-none-any.whl (58kB)
     |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 61kB 10.6MB/s 
Collecting chardet<3.1.0,>=3.0.2 (from requests->pdftables-api==1.1.0)
  Downloading https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl (133kB)
     |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 143kB 11.2MB/s 
Building wheels for collected packages: pdftables-api
  Building wheel for pdftables-api (setup.py) ... done
  Created wheel for pdftables-api: filename=pdftables_api-1.1.0-cp36-none-any.whl size=5779 sha256=3e99b8595945f9ec3251e8d27e329f14f6783353b7d98d0a3cbc5fb35de53fa0
  Stored in directory: /tmp/pip-ephem-wheel-cache-c1feg25z/wheels/49/66/c0/e4f778e772a77892a98b3aaaba300cbb27a29a07e0c225cd80
Successfully built pdftables-api
Installing collected packages: certifi, urllib3, idna, chardet, requests, pdftables-api
Successfully installed certifi-2019.6.16 chardet-3.0.4 idna-2.8 pdftables-api-1.1.0 requests-2.22.0 urllib3-1.25.3

It working, nice! Currently, We have isolated python 3.6 virtual enviroment and successfully installing required pips for Pdftables dependencies and now, let have some fun 😍

Top comments (0)