Python Development in Spacemacs

Sdílet
Vložit
  • čas přidán 6. 09. 2024
  • Post Editing Notes:
    1. `spc spc` and then `workon` to find the command for switching virtualenvs. It's not clear in the video. Apologies for that.
    2. the packages I install are flake8 isort yapf python-language-server
    In this video I cover the absolute minimum setup for doing Python development in Spacemacs.
    - I start off with a discussion of Python virtualenvs and how to get them set up correctly for Spacemacs.
    - Then a discussion of code completion.
    - Afterwards I show how to explore and fix issues found by a linter (flake8)
    - And then go over how to run scripts from inside emacs.
    - Finally I demonstrate a language server based completion backend.
    Twitter: / safijari
    Channel github: github.com/saf...
    Thumbnail Background by Dave on Upsplash: unsplash.com/@...
    #spacemacs #python #development

Komentáře • 47

  • @TheRealPrunebutt
    @TheRealPrunebutt Před 3 lety +4

    Timestamps:
    1:00 - Virtualenvwrapper
    2:04 - Additional packages for working in Spacemacs
    2:43 - Configuring Spacemacs
    3:20 - Company-complete
    4:25 - Jumping to the definitions of a variable or class
    4:56 - Linting
    6:16 - Yapify (Autoformatting)
    7:01 - Executing scripts inside of emacs
    7:32 - Code completion with LSP
    8:20 - Forcing a code completion backend

  • @earltan739
    @earltan739 Před 4 lety +7

    Thanks jack, love your content. Please make more videos on spacemacs, also please make a video for ipynb

  • @xXneorlinXx
    @xXneorlinXx Před 4 lety +6

    dap-mode works for me out if the box in, like, 70% of time. But those other 30% are hell. It either won't work or simply crash in the middle.
    Definitely needs more work :)

  • @jiyanjonasschneider4851
    @jiyanjonasschneider4851 Před 4 lety +2

    I absolutely love your videos! Looking forward to every single one

  • @ananon5771
    @ananon5771 Před 4 lety +4

    nice and informative,hope you get dap working soon though on your main machine

  • @GopakumarS
    @GopakumarS Před 4 lety +1

    Everyone says nothing beats emacs. Auto complete is a basic feature for any ide. And you say it will break some times/ may not work in Some scenarios and you need manually enable it. Why would someone take this much effort to install and configure emacs. Why can’t we just use VS code, atom, something. Those are light weight and easy to configure.

    • @JackofSome
      @JackofSome  Před 4 lety +2

      I'm fastest in Spacemacs. I've tried all the other tools for a long time and I'm fastest in Spacemacs. Some times it's finicky to configure, yes. But the time lost there pales in comparison to the time gained elsewhere.
      At the end of the day, use what you're most comfortable with. For me that's Spacemacs :)

  • @user-bj3jk5gd1s
    @user-bj3jk5gd1s Před 3 lety +1

    hi, when I type M-x: company-complete, it shows-> company not enabled, could anyone help me?

    • @JackofSome
      @JackofSome  Před 3 lety

      M-x company-mode
      Ideally you want to enable it in your config file. For spacemacs I think that's the autocomplete layer

    • @user-bj3jk5gd1s
      @user-bj3jk5gd1s Před 3 lety

      @@JackofSome I just do step by step with the vedio after git clone the spacemacs.d,maybe I should do something not mentioned in the vedio?

    • @user-bj3jk5gd1s
      @user-bj3jk5gd1s Před 3 lety

      @@JackofSome I have solved it, but a new problem come: I must run an Inferior Python and import the same lib, then the auto-completion worked of this lib in the .py file

  • @amineacademy1544
    @amineacademy1544 Před 3 lety

    my 6th or 7th sub in 8 years

  • @glennoberlander5005
    @glennoberlander5005 Před 2 lety

    Did you ever figure out how to get dap-mode going? Also, I think this video could use an update, considering how prevalent LSP's have become. I don't think pyls is used much anymore (but I could be wrong)

  • @dlf5232
    @dlf5232 Před 4 lety

    spacemacs works fine with conda backend using the condo layer. I don't know if that was true when this video was made. It only works with the develop branch though.

  • @PraecorLoth970
    @PraecorLoth970 Před 4 lety +1

    Hey, thanks for these videos! I'm loving to learn about spacemacs. If you could do one video about latex and auctex I would be very happy. Also, what's holding me onto pycharm is its debugging features. How does spacemacs compare in that regard?

    • @JackofSome
      @JackofSome  Před 4 lety +1

      It's possible to do in Emacs (see dap-mode) but I couldn't get it to work for this video. I personally stick with ipdb so hadn't tried dap until I made the video. If I get it working in the future I'll make a video about it.
      Thanks for watching :)

  • @bemotic
    @bemotic Před 2 lety

    It is so good, thank you very much!!!!

  • @xStefaKO
    @xStefaKO Před 3 lety

    Is this all the configuration I need?
    I am on Windows 10, Python 3.9.2 interpreter installed globally and using spacemacs, everything enabled in the layers(python+lsp), I make a virtual env. with python -m venv environment-name, activate it, install the dependencies I need, for example, let's say I use Pyright as a language server(which I currently am trying to do), I install npm and using npm I install the Pyright(as it's instructed in the spacemacs docs), after am done with all the dependency installations, I open up spacemacs, TRY to switch to the virtual environment using pyvenv-workon and it spits out JSON-readtable-error 80, nothing else in the error buffer so alright, what the hell, maybe it still works...
    I open up a project, it RECOGNIZES the environment I activated(down there on the modeline, it spells out its name), but it doesn't see a language server?
    I assume using built in venv is similar to this, but I don't know what I'm doing wrong...

  • @geez6666
    @geez6666 Před 4 lety

    Yes DAP mode setup is pain. After setting a breaking point using dap-breaking point-add I'm not sure how to proceed and run the script so that it gets picked up the the debug environment.

  • @derkling
    @derkling Před 4 lety +1

    Great video! I also notice your desktop setup, looks like you are using i3 as WM replacement for XFce.
    That's my setup too and I find it very convenient.
    Do you have a video where you show how to get it?

    • @JackofSome
      @JackofSome  Před 4 lety +1

      Not yet but I'm thinking about making one.

  • @muhammadzulfaqarazmi5964

    Great content, I used the lsp mode when configuring the C++ and it is great. Off-chance, will you do a video about configuring ROS in Spacemacs?

  • @MrMangkokoo
    @MrMangkokoo Před 4 lety

    do you experience lagging/stuttering with lsp? cz mine does to the point where it's unusable for me ;(

  • @picosdrivethru
    @picosdrivethru Před 4 lety +1

    so how do you deal with data processing scripts that produce a lot of output? write to disk and open file?

    • @JackofSome
      @JackofSome  Před 4 lety +1

      Either that or switch back to using a terminal

    • @picosdrivethru
      @picosdrivethru Před 4 lety

      @@JackofSome ah okay. I'm on a windows machine due to some dependencies, so this is going to be interesting :) thanks for the videos!

  • @Sahilbc-wj8qk
    @Sahilbc-wj8qk Před 4 lety

    Not working as when i open work-on it does not show any working env name i created

  • @RichardThomas341
    @RichardThomas341 Před 4 lety +1

    Thanks for this. Would you list everything that you installed, please? It would be very helpful. Thank you!

  • @dalanicolai
    @dalanicolai Před 4 lety

    Do you set your WORKON_HOME environment variable in the user-init section of your .spacemacs file? Because even though I define the variable in my .bash_profile file spacemacs complains - at least on my system where I run the emacsclient at startup with systemd - that WORKON_HOME is not defined. Or do you use a more elegant solution?

    • @JackofSome
      @JackofSome  Před 4 lety +1

      I've actually never had to deal with it. Does it work ok if you launch it from a terminal?

    • @thatoneuser8600
      @thatoneuser8600 Před 4 lety

      @@JackofSome Same problem here, after pressing " " and going to pyvenv-workon nothing happens and at the very bottom the text reads "Can't find a workon home directory, set $WORKON_HOME". It does work when launching emacs from the terminal while using the env as a source, so thank you for the help!

    • @JackofSome
      @JackofSome  Před 4 lety

      I see. I think you can explicitly set an environment variable in your Spacemacs init as a last resort. This is getting a little in the "not quite solvable in the CZcams comments section" territory. I wonder if it's time for the discord server to come into existence

    • @thatoneuser8600
      @thatoneuser8600 Před 4 lety

      Jack of Some sorry I didn't mention this earlier, just to let you know I never tried setting the WORKON-HOME variable, mine is just blank

    • @thatoneuser8600
      @thatoneuser8600 Před 4 lety +1

      ​@@JackofSome I found out that you can activate virtualenvs in spacemacs instead of doing it in the terminal, it's just pyvenv-activate in M-x and then you goto the env directory of your choice.
      @dalanicolai This article helped me set-up pyvenv workon properly - realpython.com/python-virtual-environments-a-primer/ (scroll down to the "Managing Virtual Environments With virtualenvwrapper" section)

  • @guiAI
    @guiAI Před 4 lety +1

    Hey, maybe im being the biggest noob but i dont have the 'company-complete' command, maybe im doing something wrong?
    Im using SPC + SPC to go to M-x and when i write comp... nothing pops up, or nothing relevant or similar to what you proposed, help please :'[
    UPDATE:
    so i uncommented auto-completion from the dotfile and now the command company-complete appears BUUT if i try to run it, it says that company-complete is not enabled
    HALPP
    Another UPDATE:
    I fixed it, its kinda wonky, it doesnt look as good as yours but ill be workin on how to improve it, anyway, thanks

    • @JackofSome
      @JackofSome  Před 4 lety +1

      Oh boy. Sorry I ignore Windows so hard in my videos but I don't think my old heart could take trying to make things work in Windows. I salute your initiative sir 👍

  • @arnav7000
    @arnav7000 Před 4 lety +1

    Do a video on Ruby on Rails development on spacemacs

    • @JackofSome
      @JackofSome  Před 4 lety +2

      That would require me to first learn Ruby and Rails 👀

    • @arnav7000
      @arnav7000 Před 4 lety

      @@JackofSome no problem bro take ur time 👍

  • @4kstreamer44
    @4kstreamer44 Před 2 lety

    would you care to make a new guide with the new and hip pipenv?

    • @JackofSome
      @JackofSome  Před 2 lety

      I unfortunately don't use pipenv and no longer use Spacemacs otherwise I would

    • @4kstreamer44
      @4kstreamer44 Před 2 lety

      @@JackofSome No problem! What do you use now?

    • @JackofSome
      @JackofSome  Před 2 lety

      My own immitation of Spacemacs. Started from a blank emacs config and slowly built it up until it was to my liking.

    • @4kstreamer44
      @4kstreamer44 Před 2 lety

      @@JackofSome sounds really interesting