Q:

Emacs Company-Jedi Python3 auto completion

I am trying to setup company-jedi to autocomplete for python3. The autocomplete is working for standard python3 modules; however, it is not working for packages I installed using pip3, in this case numpy.
The virtualenv package required by company-jedi has been installed using:
sudo pip3 install virtualenv

Python3 has been installed using:
brew install python3

Numpy was installed using the following command:
sudo pip3 install numpy

I have followed the instruction from this link but to no avail. If I install numpy using pip instead of pip3 auto-complete works; therefore, I think that jedi is still using python2 instead of python3. The command M-x jedi:install-server does not return any errors.
The path of python3 was determined using the command which python3.
The exec-path-from-shell package is used to make sure the environment variables on emacs match those in the shell. Without this package the function M-x jedi:install-server returns an error that virtualenv does not exist.
My question is, how can I setup jedi to use python3 for auto-completion instead of python2?

Init.el
;; To get path from shell
(use-package exec-path-from-shell
  :ensure t
  :config
  (when (memq window-system '(mac ns x))
    (exec-path-from-shell-initialize)))

;; Installing company mode
(use-package company
  :ensure t
  :config
  (add-hook 'after-init-hook 'global-company-mode))

;; Disable the delay
(setq company-idle-delay 0)

(eval-after-load 'company
  '(progn
     (define-key company-active-map (kbd "TAB") 'company-complete-common-or-cycle)
     (define-key company-active-map (kbd "<tab>") 'company-complete-common-or-cycle)
     (define-key company-active-map (kbd "S-TAB") 'company-select-previous)
     (define-key company-active-map (kbd "<backtab>") 'company-select-previous)))

(use-package company-jedi
  :ensure t)

(defun my/python-mode-hook ()
  (add-to-list 'company-backends 'company-jedi))
(add-hook 'python-mode-hook 'my/python-mode-hook)

;; Python
(setq python-shell-interpreter "python3")

(setq jedi:environment-root "jedi")  ; or any other name you like
(setq jedi:environment-virtualenv
      (append python-environment-virtualenv
              '("--python" "/usr/local/bin/python3")))

I am currently on MacOs version: 10.13.6

A:

Are you using Python 3.7? Jedi doesn't support that version yet and so falls back to the next highest, which on most systems should be 2.7.
There's a couple of things you can do: You can simply wait for Jedi to support 3.7 which shouldn't take too long. You could also downgrade to 3.6. Or you could manually add 3.7 to the supported versions in the Jedi code. Supported versions are defined by the variable _SUPPORTED_PYTHONS in the file jedi/api/environment.py within the Jedi package. Since you probably shouldn't mess around with globally installed packages, it might be best to first copy the package to your virtualenv (something like cp -r /usr/lib/python3.7/site-packages/jedi ~/.emacs.d/.python-environments/default/lib/python3.7/site-packages/) and then edit the file there.
Since Python 3.7 isn't officially supported, this last way might cause some issues with using Jedi in Emacs. Also, since the package in the virtualenv overrides the global one, don't forget to remove it once actual 3.7 support arrives in Jedi.

