#tools-and-devops
1 messages · Page 35 of 1
but if I use the terminal and access manage.py
I get this error:
ModuleNotFoundError: No module named 'fasgmc'
fasgmc is an old project that has no relation to this project
here is the file tree of the new projectL
settings.py and wsgi both have the correct project name wherever it would be needed
I assume this is a pycharm issue
and ran into similar things with flask
r u using virtual environments? idk if that could be the problem but mb?
pyCharm created a new venv for this project
(at least that is what it is supposed to do)
I am trying to run manage.py from here:
(venv) C:\Users\domdi\PycharmProjects\BankInfozone>
the old project name does not show up anywhere in environment variables
ok. and just to make sure. if u run which python (or windows equiv) does it source the right venv?
(venv) C:\Users\domdi\PycharmProjects\BankInfozone>python -V
Python 3.7.1
i am not sure how to do which on windows
I am looking now
(venv) C:\Users\domdi\PycharmProjects\BankInfozone>where python
C:\Users\domdi\PycharmProjects\BankInfozone\venv\Scripts\python.exe
C:\Users\domdi\AppData\Local\Programs\Python\Python37\python.exe
could it be due to the second instance of python?
I also changed the app name from "app" to "bankapp" in case it was getting confused with fasgmc's app folder
still
nothing
are either of those executables the one that is used by the old project?
yes the second one...
so that is the culprit
any idea how to get rid of that in pycharm?
nevermind. the pycharm terminal has its own environment variables apparently
Goto File->settings -> Tools (v) -Terminal
edit the envvars
and u will see somehow there is a DJANGO_SETTINGS_MODULE in there
cool :D so u got it working?
I got it working then decided to switch to flask because the smaller size of the project 😃 so a nice waste of time on a tuesday
y'know... sometimes it be like that
not a huge waste though, you may run into it again in the future and now you know what to look for
Never a waste! I'll bet you know more now than you did before :)
^
hey so my vscode window freezes whenever it runs the linter, formatter or that kind of thing,
every time I save it creates a new python file named the same way except it has an hash between the name and the file extension, and deletes it when it's done doing its thing ( takes less than a second )
my file is 700 lines long, mostly made of functions that I don't use while I'm working on a new one,
I was wondering if the freezing was caused by the 12 import statements at the start of the file ( most unused ), or if it's just the file that is too big and has to be rechecked as a whole every time ?
here is my list of packages :
astroid 2.2.5
attrs 19.1.0
autopep8 1.4.4
beautifulsoup4 4.7.1
CacheControl 0.12.5
cachetools 3.1.1
certifi 2019.3.9
chardet 3.0.4
Click 7.0
grpcio 1.21.1
httplib2 0.13.0
idna 2.8
isort 4.3.20
lazy-object-proxy 1.4.1
lxml 4.3.4
mccabe 0.6.1
msgpack 0.6.1
pdfminer.six 20181108
pip 19.1.1
protobuf 3.8.0
pyasn1 0.4.5
pyasn1-modules 0.2.5
pycodestyle 2.5.0
pycryptodome 3.8.2
pylint 2.3.1
pytz 2019.1
requests 2.22.0
rsa 4.0
setuptools 40.8.0
six 1.12.0
sortedcontainers 2.1.0
soupsieve 1.9.1
toml 0.10.0
tqdm 4.32.2
typed-ast 1.4.0
uritemplate 3.0.0
urllib3 1.25.3
wheel 0.33.4
wrapt 1.11.```
I'm running Python 3.7.3 32bit on latest vscode with the microsoft Python extension
hm, one way to debug would be to create a new file with just one function, then run it and see if you get the same issues
700 lines is quite a lot for a single file
yeah it gets worse with the more code I add and I don't have this problem with a 50 lines one
I have a few os.listdir(path) targetting like 20k files total in the functions I don't use, could be that too idk
here is the cpu profiler when I hit save
yeah it comes from microsoft's python extension
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/AvianAnalyst/AvianAnalyst.github.io.git/'
I know i've entered the right informatin (and i've tired about four times) I think it might be because i've turned on 2fa? but idk how to account for that. Any help?
ty
Ok, so I got that set up (thank you again, ELA), and I'm trying to see how you can store it as an environmental variable and then use that. Do you guys write a push script that you run to push your changes to the remote, or am i missing something?
ohh ok thank you!
Can someone point me in the general direction of navigating (pressing buttons) this website? https://ovaspin.walkingtoweb.com/fmi/webd/PT_Suche I tried using Selenium, but I can't access elements, as the site uses some kind of weird script
would you guys recommend installing docker on windows10
If you need docker, yes
I would like to fiddle with it, some people told me that docker on windows is weird and messy
why dont VS code depug my py file ?
it was warking
only I do F5
now when I do F5 it doesnt run
help
@saki hyper-v has to be enabled. Docker may automatically do this for you. Problem is that enabling hyper-v makes VMs stop working. You could disable hyperv again of course but that requires a reboot every time you need to toggle it.
@vivid cargo I don't think that tagged you at first oops
For what it's worth I currently handle my docker needs inside a Linux VM
Really using a VM.for Linux is not bad
it is kind of bad
VMs are such hogs, just switch to linux for dev and fall in love with it 😃
I'm thinking about it since i'm running out of space on my ssd and i got a job starting in september
hype
I'm using VMware
I don't do anything performance intensive so the experience feels smooth for me
And with that said, I don't know if performance intensive tasks would be bad anyway
I'm leaning more towards ssd
I know but i've only got 40 more gigs
VM or no VM, if you had space, you could just partition the existing one and install linux there, no need of a new ssd if you had space, installing linux would take exactly as much space in a partition as in a VM
partitioning on windows is confusing to me
you can do it through a live usb, but last time i had to reduce a partition from windows, it wasn't really as bad as before
I have linux installed on my laptop, but it's very old
I am thinking about separate ssd just cuz i want to be able to transfer my workspace everywhere i go
@vivid cargo thats not a bad idea, you can mount your work at /work or something on linux, and whatever the equivalent would be on windows
The Prob. is that my IDE debugger stops in the last 2 days
Which IDE?
@warped cliff i dont know the answer but its possible that you installed a new plugin or installed an update that broke a plugin
There's a config file you may need to set first
How to change the text color for Python in Hyper.js?
I mean, it would be like:
def is red
integers are blue
break is yellow etc
Like how it is on the Pycharm
When I install anaconda 3 on mac, why does every new terminal I open now have a (base) virtual environment?
@hidden lily it looks like it's activating the base conda environment
how did you install it?
@turbid cipher https://github.com/paulmolluzzo/hyper-color-command
@tawdry needle
I just download it
Gonna check these when i get the laptop, thanks
@tawdry needle with the official macOS installer package. And yes that’s what’s happening. But why? Is this normal behavior? What is it potentially messing up?
@hidden lily i think its a little presumptuous on their part to include that in the installer
was it a "system wide" install or a "user" install?
im not familiar w/ the macos installer but i know how conda/anaconda works and i know how macos works
I would guess it added something to the bash profile file
to make it activate an env
just a guess though
@tawdry needle user install. Presumptive is a good word because before it was doing this, the Mac installer was overwriting the default “python” shortcut in the shell to its new version, even if that meant going from 2 to 3
well it cant really do that
So I’m not sure who controls that or why they seem to love messing with systems
it likely changed something in your ~/.bashrc file
It doesn’t uninstall it, no, but replaces where the shell finds Python
yeah it cant do that as such
what it can do is add stuff to ~/.bash_profile or ~/.bashrc
can you open those files in a text editor and see?
it will say something about $PATH
or conda activate
# added by Anaconda3 2019.03 installer
# >>> conda init >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$(CONDA_REPORT_ERRORS=false '/Users/kamuela/anaconda3/bin/conda' shell.bash hook 2> /dev/null)"
if [ $? -eq 0 ]; then
\eval "$__conda_setup"
else
if [ -f "/Users/kamuela/anaconda3/etc/profile.d/conda.sh" ]; then
. "/Users/kamuela/anaconda3/etc/profile.d/conda.sh"
CONDA_CHANGEPS1=false conda activate base
else
\export PATH="/Users/kamuela/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda init <<<
Added to .profile
anyone have a pycharm theme/color scheme that correctly mimics vscode? all the ones ive seen are garbage
@manic minnow it's probably not hard to build one if you really know what you want
i mean, i didn't do any color theme for pycharm, but i did for vim and it's not hard, i imagine it would be not a lot more complex for any editor that didn't decide to make things awefuly complex for no reason
Yup it just takes some time. I made a visual studio theme for ida. That's was more involved since its assembly and didn't translate 1 to 1
anyone know a good IDE for c++, python, webdev (html,css,php,js) or most of these languages in one? I don't want to download a bunch of IDE but maybe that's best what yall think? Please @ me if you respond.
You see IDE usually means that its specialised in one language, you either cant get the other languages in or gotta download a bunch of plugins @white arrow
if you want support for a lot of languages you don’t usually get the full features an IDE has to offer
for Python+webdev though VSCode comes to mind, but I’m not sure about how VSCode plays with C++
Visual Studio supports many languages. So does IntelliJ IDEA, but requires plugins
Neither will be "good" for all languages
Everything by Microsoft plays well with c-family
This was the best place for me to ask, why isn't there a button on a GitHub page that leads to the releases. When I want to download a release I always type /releases behind the URL in the address bar
Or is there one?
on the main repo page, do you see a horizontal section with a thin coloured bar below (that's the repo language composition btw) that shows the number of commits, number of branches, number of releases, number of contributors and license? it's below the description+tags, and above the repo file structure section
unintuitive design? iunno :p
github's UI really isn't good, we all just got used to it
they purposely refrain from adding buttons and things to it, as there is so much you could add that you'd quickly make it illegible, some features are only available by editing the url directly
what it really needs is bitbucket style commit/pull diffs
you can add .diff to a commit url to get that, or to a PR
well, not sure it's what you asked for, but it's a diff 😛
nah just the ui for the full list of changes is quite hard to see at a glance. you just get a sequential list of files instead of it being rendered as a directory tree
how about, they actually give me a button for the compare UI, instead of me having to type /compare/foo...bar in the browser
or make it less than 1,000 keystrokes to view the tree at a commit hash and not by its branch/tag
thinking about self hosting gitea or something, idk. gitlab is too "industrial" feeling, its ridiculously feature-rich. the UI is really information dense
gitlab is kinda perfect for collaboration i guess. idk, the world needs the "one true bug tracker"
maybe launchpad. idk
Let's say you get into a situation where you push to a branch but later realise that upstream has had the same commits rebased (e.g. cause a previous PR of yours was accepted by rebasing) and now every commit of yours is different. How would you fix it? Right now I have been using this sort of clumsy approach: bash git format-patch hash git reset --hard origin/master git am -S --committer-date-is-author-date 000*.patch rm 000*.patch
I was thinking about an interactive rebase, where I'd break before my new commits start and do a reset there. That would be simpler if it works
i am looking for command line editors and found micro
https://itsfoss.com/micro-editor-linux/
https://github.com/zyedidia/micro/releases
i want to ask you guys, do you recommend anything other than vi/vim based CLI editors
nano?
emacs and vim "suck" because the skill level required to make efficient use of them is quite high, if you actually know the editor you can do incredibly efficient things which might take you minutes or hours in a normal text editor @vivid cargo
Not what i asked but okay
Is anyone using PyCharm with pyenv? And if so, how do you setup the default project interpreter when creating a new project?
Is Visual Studio Code good?
@eternal flicker are you using pyenv-virtualenv or just pyenv? in either case i think its a matter of selecting the right option and then navigating to the python executable
so File -> Settings -> Project -> Project Interpreter
then theres a little "gear" icon
@blissful sable
One of best out there
if you learn vim or emacs, you know you are set for the rest of your career, no need to learn a new one every 3 years or so
you'll spend the rest of your life fine-tuning your configuration though, and be unable to program on another dev's machine, and people won't be able to pair program with you on your own either
but it'll be great anyway
correction: "you'll spend the rest of your life trying to exit vim"
i was asking for some cli based editors, not persuasion to try vim again
sorry, came in the middle of the conversation
there's always nano
oh lol you mentioned you were moving away from that
well what don't you like about emacs
and for that matter what don't you like about nano
hard tyo make a recommendation without knowing what you're looking for
@vivid cargo
I don't like emacs because it has weird keybinding that everyone loves
I just can't get used to it
I love nano but i want to try to move away from it and see if there are any other cli editors
I found micro
Seems okay
Not everyone loves emacs bindings, and they can give you RSI… but you can use vim bindings in it with evil mode
Even worse situation
The ones it shares with readline are useful all other the place though, so worth learning
I would love if somebody developed a new suite of emacs bindings
Vim bindings kind of suck too
And can be even worse with international keyboard layouts
I completely agree
i mean, in emacs the regular keys like arrows, home, end, holding shift for select (in gui mode anyway) work normally, and the other commands aren't really any more weird than most other text editors
i don't use it personally (too much into vim), but it really doesn't seem any harder than nano to use at the level of nano.
i do want to learn more emacs some time
i'm in a kind of weird position with editors in that i like emacs better, but I'm better at using vim
same. one day ill switch to evil
my big hangup with vim is that it really embraces the "composability" aspect
i hate in emacs how everything is its own command
forward-word, forward-character, etc
the whole idea of command+motion is really powerful to me
@barren iron are you interested in a pretty website for your tool? one of those hip "2019 software" type of sites. i have a web dev friend looking for portfolio work
He is more or less a webdev guy himself @tawdry needle
Yeah @tawdry needle , I quite like doing everything myself.
Sharpops is going to take along time to get to the stage of needing a website
👍
@tawdry needle Does your friend happen to enjoy the design side more than the implementation side?
I'm currently building a portfolio of websites I build + host, would be happy to have someone to design for me
I have a few clients lined up
@barren iron yep design
@tawdry needle Ok. if we both need experience... can I get in touch with him?
We can maybe share clients, double the portfolio
yeah @barren iron let me get their best contact info
they have a discord acct but i dont think they use it
Ok
Am I using pip and friends correctly? I have one package which depends on another, but I actually have a forked that dependency on my own github. So in the first package, I have requirements.txt with -e git+https://github.com/.../#egg=dependencyname. I got somebody to install the package with pip install -r requirements.txt, then pip install -e ., but the import dependencyname doesn't work (ModuleNotFoundError)
Does it work for you though?
It could just be an issue on their end with their commands
For example pip could be for Python 2 and they're using python3 as the command to run the program
That's a common scenario
Yeah, it works for me... I didn't think about Python versions, I'll check that
Maybe they have Python 3 default but pip2 or something, because I'm using f-strings which won't work on Python 2
usually it's recommended to not call pip as system command but instead python3 -m pip or whatever the interpreter command you use for your application is
Oh really? I've never heard that before
I suppose that is a good way to ensure you're getting the right version
If you are on linux, install python3-pip
Not python3-pip ?
My bad
you guys any tool to move programs from one disk to another?
windows
Default file explorer
Hi, I'm looking for some package to test my programs efficiency. On the web, I've found tons of such packages, but I don't know which one should I choose. Measurement of the time of execution is simple, but what about examining RAM or CPU load?
Heya, is someone familiar using IPython in jupyter?
Any idea why pycharm's run console isn't outputting PyQt stuff? Makes the debugger pretty useless when I don't see warnings
I am just starting to mess around with the pycharm debugger
I still don't quite understand it
Anyone know anything with regards to git? If I work on one file and make a new branch and change that file, shouldn't I be able to switch between branches and then have different versions of that same file?
or do I need to rename the file
@sand thistle no need to rename, that's the point of branches
Just git checkout to the branch you want to work on and git will automatically adapt the files accordingly
everything commited is “saved”, just remember that
but
hmm
for example I have a file called PyPDF.py
it's in two branches, however in my most recent one I wrote different code
when I git checkout to the branch I want to work on, nothing changes in my PyPDF.py file
did you really commit it?
I believe so
when I do git log
it shows different stages
hashes and labels
I also have 2 heads
yeah but that does not tells whether the file has been commited or not
how would I check
please show the result of git status
@sand thistle here you go, you have not commited any of these files
I thought that meant the red text wasn't comitted
im like 100% positive I commited the originaly PyPDF.py
so then why do I have different hashes in the git log
I was under the impression that after you commit
you are to label the changes in the log
yes, but you have to git add the files you want to commit
otherwise they are not considered part of the commit
do git status after git add to check the files that are staged to commit
? ok but that doesn't help me
like why is the log still there if the commit doesn't exist
I don't understand
the commit exists
but you're saying it doesn't contain my file
this makes no sense.
if it has my pipfile..
then why wouldn't it have my .py file..
can I revert to a commit then?
since it seems to be hashed, then I should be able to switch to that version which would have my file?
I am create a QT application which is rapidly growing, I am getting to a stage where I kind of need to break it up a bit but am unsure how. Do anyone know of any articles that talks about this? Or maybe a good structured open source QT application that I can take inspiration from?
How come when I run a code inspection in Pycharm which results in both warnings and errors, they are all grouped under "Warnings", even though I've enabled grouping by severity? I would've expected there to be one category for each severity level.
Now I have to sift through hundreds of warnings to find the 5 errors.
Can a request made in Postman be exported to e.g. HAR?
Maybe that's not what I'm looking for even
Just want an easy way to share with someone how I did the request (all the headers and content, etc)
you can show the postman console and extend everything in the log of that request i guess
Ah yeah that would work. Didn't know it had a console even
not sure why they don't show it more, it's quite useful
sometime you have no idea what the error postman spits is about, and the console says it all
who needs postman if they can use curl...
Is there any tool bot to help one deleting his messages on discord after an amount of time? Assuming that he has no permission to add the bot to the server.
No, automating any actions using a user account (not bot account) is not allowed by Discord's ToS and might get you banned.
😂 Thank @lost rock
Hey how do I use anaconda envs in atom
@lost rock that's what i though, too, but saving/documenting calls in postman, is pretty convenient, for us it allows the products people to investigate api we want to integrate, as well as check the api we implemented, before releasing, we can save examples of the results of various calls, and it's shared between everybody. I can see the point.
anyone else get indexing again every single time you close/reopen pycharm?
it also happens every single git branch switch
the ide becomes unusable and almost maxes cpu every time
until indexing is done
yep, and skeletons
I'm trying to get python packaging tools installed in pycharm I'm not sure what I've done to it 😦
but when I click install python packaging tools in interpreter settings I get failed:
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.1.3\helpers\packaging_tool.py", line 155, in main
do_untar(name)
File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.1.3\helpers\packaging_tool.py", line 92, in do_untar
import tempfile
File "C:\Users\mobil\AppData\Local\Programs\Python\Python37-32\lib\tempfile.py", line 45, in <module>
from random import Random as _Random
ModuleNotFoundError: No module named 'random'
could this be a symptom of me not being able to use import random so I found the random.py file it referred to and copied it to my directory to allow me to use import random?
I'm tempted to just uninstall python copy data project files, uninstall python and reinstall both
ok, well I guess I was using the wrong interpreter as Im able to install random now
and pygame
Is it possible to configure the scope of a coverage analysis in Pycharm Pro 2019?
@heavy berry something is really wrong if you can't import a stdlib module. you shouldnt ever have to "install" it
@dire quartz Not that I know of. I configure it with .coveragerc, which PyCharm will read
@tawny temple Oh, right. Well, that also solves my problem, thanks.
Has anybody found a good Docker Image or Software that is fairly straightforward to wrap that can function as a Mail Server for Flask-Mail?
I've looked a few options but haven't ever used a mail server so I'm not sure what I need to be evaluating
I've not tried this myself but had it recommended to me https://github.com/tomav/docker-mailserver
I've configured a mail server myself (basically did most of what I linked but I did it manually)
And it was hell to figure out some stuff
There's lots of bits and pieces
Yeah it seems like something fairly complex, and I'm just looking for email confirmation for user registration on a small freelance app
I will take a look, thank you!
Unfortunately it's been a while so I don't remember the details
Some stuff you'd probably want is a spam filter and DKIM or something
I don't remember it all
How easy is it to make your own MX server
There's stuff you need to set up for your DNS
Yeah I've done some of the DNS work with GApps
Who's your registrar?
Namecheap has email forwarding built in if you use their DNS
I dunno what can be left out for forwarding. I worked on a full blown thing
I've really only done it once and it was for fun not for production use so I'm not a great person to explain this stuff
For completeness, it occurs to me that Google Apps is a mail server... and viola! https://www.twilio.com/blog/2018/03/send-email-programmatically-with-gmail-python-and-flask.html
can i fiddle with venv within the code?
like making and activating it within the script
without calling os.system()
I think you can e.g. import venv and call stuff there directly, yes. Check the docs for the module.
i've been swimming through the docs and i can't find anything
i can't find anything mate
never used it either, but that's the classes and functions it offers
guess you'll want to use venv.create(...)
@lost rock do you have some actual code examples/tutorials about this?
i'm kinda confused
nope, never used it. Your googling is as good as mine there.
to activate a venv you can exec the venv/bin/activate_this.py script in
The docstring at the top shows you how to do that
yeah, but within actual code
wdym?
You can activate it within code
that's exactly what the docstring shows how to do
def create_venv(dir: str):
virtualenv = venv.EnvBuilder(with_pip=True)
virtualenv.create(f"./{dir}")
return
how do i now activate the venv
I explained that above
any way to get pycharm to bark at me for undefined attributes in classes? For example self.letter in here
class Test:
def __init__(self):
self.number = 5
def print_stuff(self):
print(self.number)
print(self.letter)
pylint does that, maybe you can make pycharm use it
anybody using rope with vim? it seems installing it and the ropevim plugin has no effect at all for me
i can import rope in python, but i get none of the rope commands in vim
@pure pulsar thanks! Won't be pushing silly mistakes anymore 😄
even complains about my 21 methods, it's great 😛
So uhh
whats the difference between github wiki vs github pages
when should I use one over the other?
Wiki is just simple markdown formatting and can be thought of as part of your repository
cause it's just a "tab" on your repo
github pages is a full fledged website
ok, so what should I use for documentation
gh pages says you can source from the /docs folder
but wiki says you can put docs there
so im really confused
GH Pages would be better if you're like using sphinx or something
and then you can host a frontend for those docs with gh pages
You can go either way
depends how fancy you wanna be
Indeed plenty projects just use the wiki
how can I make it?
yeah, like I use gh pages as a frontend hosting
and then I use like idk
heroku or smth for backend
and have them work together
I need it 100% free btw
But essentially I am using gh pages as a domain name and frontend hosting, and some other service for backend hosting
yeah thats what im saying, how can I use a different service with github pages to host a dynamic site
Ok this isn't a serious suggestion but you can just have ajax requests to load the site from heroku or wherever
I've not use GH pages myself so I'm not the best person to ask
hmm
well I found this: https://medium.com/pan-labs/dynamic-web-apps-on-github-pages-for-free-ffac2b776d45
In the (very near, like DAYS near) future I will be publishing articles on:
• How to Use Heroku + Firebase to Make a Free api Server
is from 2017 and has never made the article
@tawny temple
this is what windows venv looks like
i can't use activate_this.py on windows
so os.system() is needed?
No
i tried to cat activate, activate.ps1 and activate.bat
all shell scripts
using the shell scripts is not the way to go
i figured that out
instead of __file__ specify the path to the Scripts folder
I forget if __file__ also contains the file name
or if it is only the directory
activate_this = '/path/to/env/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))
do i have to point it to the venv?
No that's wrong but you made me realise L17 doesn't need to change cause you can specify it in the dict
this_file = '/path/to/env/bin/activate_this.py'
exec(open(this_file).read(), {'__file__': this_file})
aaah
But this means you'll need to move activate_this.py into venv/Scripts first
The entire script operates on the assumption that the script is located in that directory
yeah
Well
that what's messing with me
I guess you don't have to physically move it
Maybe changing the value of __file__ is enough
So you'd need two variables: 1 for the actual location and one for the fake location for __file__
umm
open() of course needs the actual location
so, i'm going to run this project on different OS-es and different systems
and if i'm activating venv on linux, that's easy
but if i'm runnning my project on windows, that's gonna mess everything up
That didn't answer my question
i'm confused about how would i go about activating it on windows
when i'm creating venv on windows, it won't create activate_this.py file
This file will be part of your project
when you exec() you just gotta give the right path and that should be it
let me see
As I discussed you need to set the __file__ to be a path inside the venv
but the path for open() needs to be the actual path to the file
so ```py
actual_path = "/my/project/active_this.py"
fake_path = "/path/to/venv/Scripts/activate_this.py"
And this method is cross-platform
The only difference is that windows calls the bin dir Scripts
exec(open(this_file).read(), {'__file__': this_file})
what here is fake and which actual
and you can easily change that by checking which OS it is
That line is really incorrect
exec(open(this_file).read(), {'__file__': this_file})
the value of __file__ in the dict is supposed to be the "fake" path
i tried creating venv with bash and powershell
and neither did give activate_this.py
@tawny temple you here?
I already said you just include that file in your project
you dont need to rely on the venv to create it
yeah but i'm reading that bash venv gives that file
okay
@heavy knot you mean the file tabs or the menus at the top?
yhe, that's wrong. you have it opened as 1 project.
can I see your files at the left side?
but thats sucky 
if you create a project with pycharm, it does that for you.
okay thanks
the thing is that it uses virtual environments, and each needs it own folder
do you know what that is?
In the flask documentation, they have a suggested project structure, using their example 'flaskr' blogging application.
In that example, they have a flaskr package, and a setup.py file. Now usually this is for something that you upload to pypi, but this is literally a blogging app, so I have no idea what it's for.
What is the purpose of a setup.py and package folder, for an application, not a package/library that you upload for others to use?
And how do I use it in my own application?
i think it has setup.py because tutorial app is on pypi
in other cases, you don't need it
requirements.txt is fine
hey @tawny temple
i'm fiddling with file from yesteday
when i'm doing
exec(open(this_file).read(), {'__file__': this_file})
where should i point this file to
inside venv/Scripts on windows, and inside venv/bin on linux?
Yes, that's for __file__
and this_file is a string path to the file i'm reading
Yes
let me try it
saki@Greg:/mnt/c/Users/KORISNIK/Documents$ python3 -m create-flask-app saki
yes db
Creating a new Flask app in ~/saki.
saki@Greg:/mnt/c/Users/KORISNIK/Documents$ cd saki/venv/bin/
saki@Greg:/mnt/c/Users/KORISNIK/Documents/saki/venv/bin$ ll
total 8948
drwxrwxrwx 1 saki saki 512 Aug 12 18:56 ./
drwxrwxrwx 1 saki saki 512 Aug 12 18:56 ../
-rwxrwxrwx 1 saki saki 2217 Aug 12 18:56 activate*
-rwxrwxrwx 1 saki saki 1273 Aug 12 18:56 activate.csh*
-rwxrwxrwx 1 saki saki 2437 Aug 12 18:56 activate.fish*
-rwxrwxrwx 1 saki saki 271 Aug 12 18:56 easy_install*
-rwxrwxrwx 1 saki saki 271 Aug 12 18:56 easy_install-3.6*
-rwxrwxrwx 1 saki saki 243 Aug 12 18:56 pip*
-rwxrwxrwx 1 saki saki 243 Aug 12 18:56 pip3*
-rwxrwxrwx 1 saki saki 243 Aug 12 18:56 pip3.6*
-rwxrwxrwx 1 saki saki 4571576 Aug 12 18:56 python*
-rwxrwxrwx 1 saki saki 4571576 Aug 12 18:56 python3*
saki@Greg:/mnt/c/Users/KORISNIK/Documents/saki/venv/bin$ source activate
(venv) saki@Greg:/mnt/c/Users/KORISNIK/Documents/saki/venv/bin$ deactivate
saki@Greg:/mnt/c/Users/KORISNIK/Documents/saki/venv/bin$
I think I misunderstood what you were trying to do
after i create venv and *activate* it, deactivate command doesn't work
Thought you wanted to activate it inside python
I don't know to accomplish that
Np
os.system() time
also, when i run os.system() does it open subshell within this shell?
so, if i'm running on cmd, it will open another subshell of cmd
and same with bash
Yes I believe it does
okay
That's why I said I don't think it will work
hmm
You'll probably need to replicate what the shell scripts are doing but in Python code
and you'll need to make sure changes persist to the environment (e.g. updating environment variables normally doesn't)
env vars only stay in subshell?
Well not a subshell but it only applies to the the Python process
(and optionally any subprocesses it creates)
In the flask documentation, they have a suggested project structure, using their example 'flaskr' blogging application.
In that example, they have a flaskr package, and a setup.py file. Now usually this is for something that you upload to pypi, but this is literally a blogging app, so I have no idea what it's for.
What is the purpose of a setup.py and package folder, for an application, not a package/library that you upload for others to use? And how do I use it in my own application?
I want an indepth answer, and I want whoever responds to know what they are talking about
in this case, setup.py is there only for flaskr to be available on pypi
that's pretty much it
I don't think that's the reason considering that PyPI package is not maintained by pallets
I'd say there is no good reason for them to have a setup.py and a requirements.txt would have sufficed
If you're not going to pip install it then it has no purpose
I indirectly answered that question
Because you were asking about applications rather than libraries and flaskr is an application too
yeah, so if a requirements.txt would not suffice, what would I do
What is the purpose of a setup.py and package folder, for an application?
Mark:
I'd say there is no good reason for them to have a setup.py and a requirements.txt would have sufficed
like, what is different from a setup.py then a requirements.txt file
It's a script for pip install
requirements.txt contains the dependencies for your app
Using a setup.py is if you want to install your own app itself rather than just its dependencies
And, again, I don't see a point in doing that for a flask app.
Installing a package is useful if it's a library cause it makes it easily available for importing from other projects. It's also useful for command-line tools so that they can be used from anywhere
ok, so I remember one time I was making this discord bot
and it had a whole lotta files and imports everywhere
I was asking about this one import question
and someone told me I should create a package instead
how do packages affect imports from within the package itself?
pycharm or visual studio?
If by visual studio you mean visual studio code, then it depends. I recommend trying out both and choosing what you like most
@tawny temple About installing installing the app itself, the flaskr app's init file has some stuff in it, does that matter?
https://github.com/pallets/flask/blob/master/examples/tutorial/flaskr/__init__.py
A package folder is for namespacing
A setup.py is for installing with a package manager such as pip
Don't know
I already answered that requirements.txt would have been enough
Just because the author of the tutorial added it doesn't mean it's undoubtedly correct
Maybe they just thought installing dependencies with it would be easier than through requirements.txt but that's preference and such a minor thing
I am not talking specifically about the tutorial
so the only point of a setup.py is for install dependencies?
does it install the files inside the package too? or just whats listed as a dependency
It installs the project and its dependencies
ok, so wouldn't that be helpful for files inside of the package?
since you could import other files from the package from within the package itself?
You don't need to install the package to be able to do that, so not it wouldn't be helpful
If you wanted other packages in other applications/programs to be able to import your app then sure, it's useful to install (and I already mentioned that yesterday)
Well I am not talking about other packages or applications
I remember once I had some whack importing issue I got myself into when creating a discord bot, and they told me I should have just created a package to install instead
and I was curious what that person meant
To be clear, that suggestion is not related to setup.py
The suggestion meant to put all your modules (aka .py files) inside a folder (a package) and then to import other modules within your project you'd do from package import module for example
If you don't have a package then I think you're stuck with just relative imports like import .module
no thats what I did already
then run your program outside the folder
before I got into the jank importing issue
I had a folder "src" with 3 other folders, each containing 3 files, and each file was it's own subcommand, with each folder being it's own command, and the src holding all commands
but then I had an issue where I wanted from one file to import the file next to it, but it wasn't working
the imports would need to be like from src import module
from src.subfolder import module
etc
yeah and it was not working, there was some really weird issue (I cant recall what)
I ended up having to import it a SECOND time in the init file under a namespace
it was weird
I believe you need to run your program like python -m src.main (e.g. if main file is `./src/main.py)
And the current working directory must be outside src
Alright, well if you want someone to try to help and take another shot at it feel free to ask in a help channel
But yeah this has nothing to do with setup.py
Why did he ask me to put it in a package? I am 100% sure he didn't mean a FoLdEr
I don't know why we'd know the answer to that
A folder is called a package
and subfolders are sub-packages
As it points out, confusingly, distribution packages are also called packages.
Work in what sense?
it has 1 function
create_app
that returns the app
where is that called?
it seems really weird to do from __init__ import somthing
so how does that work
You don't import from __init__
things in that file are considered to be part of the package
thats why I'm asking
it'd be from flaskr import something
THAT SOLVES THE ISSUE I WAS HAVING EARLIER
is it good practice to have code in init?
I read somewhere it isn't
Not neccessarily
and should only be used for importing
I only make it if I need to put something in there
Since python introduced namespace packages, a __init__.py is no longer mandatory
Anyway, the way create_app works is that Flask will detect it
In the tutorial, the package flaskr is specified as the FLASK_APP
Since anything defined in __init__ gets translated to being part of the package namespace
Flask will be able to find create_app function and use it
wtf
probably a bug with f strings
it was working fine just a while ago
i changed the method to use self.type instead of a local type variable
and then this happened
Hey so I found a video explaining my issue and the package solution @tawny temple
https://www.youtube.com/watch?v=44PvX0Yv368&list=PL-osiE80TeTs4UjLw5MM6OjgkjFeUxCYH&index=5
In this Python Flask Tutorial, we will be learning how to restructure our application into a package rather than running from a single module. This has major...
and yeah it doesnt use a setup.py
So for jetbrains ides (pycharm) there is a great extension called keypromoterX that pops up keyboard shortcuts when you use the mouse for something that has a keyboard shortcut. Does anyone know if something like that exists for VS Code?
I don't think there are events in the API to support this
There are a few related issues but none have been implemented into othe API
i couldve sworn this used to work without a hitch before
can anyone confirm if they get the same issue? PyCharm 2019.2 here
Yeah same issue
Though it wouldn't happen if you passed cd for example
By the way, you can do path.open() 😉
dude you read my mind
i was just wondering if there's a path.open
i was thinking 'nah doesnt some pythonic since there's already one way to do it'
i get the same issue with cd as well btw
something's broken
(am specifying cd's type because Path.parent doesnt have a type annotation apparently. or pycharm's not picking it up correctly at least)
I assume it's a no given the reactions I got a while back but I am still looking for an option to code on my tablet, which is in another room from this desktop, unfortunately pycharm won't work on it and that interface is what is conducive for my coding experience I don't like the split up nature of the free ones online anyone in here use codeanywhere.com?
I’m having that same pycharm path issue, 2019.2.
Guys which IDE is best for beginner python programmers?
Only 2?
https://pythondiscord.com/info/resources has some editors and IDEs near the end of the list
there are for sure more than two. PyCharm is just probably the best known and generally most advanced. Probably not the ideal beginner's choice though for that reason.
@lost rock Thank you

Or Sublime Text
But I rather recommend vim
At first you will look like a turtle
But after two months of constant work and programming
You will look like you are high on adderal
So why is vim better exactly?
- You get faster and faster, therefore, you get more efficient
- It's VERY lightweight
- You can customize literally EVERY part of it
- You look cooler B)
PD: I have recently used vim to design some web page, and man, I have never had to touch the mouse or something like that
So confortable
Lmfao
I want to get better at programming with just a keyboard, but most of the programming I do is web based, so I'm switching tabs and interacting with sites a lot
you can switch chrome tabs with ctrl+tab
firefox too! reverse direction with ctrl+shift+tab
@vivid cargo interacting with sites
honestly tho
thats what I do
just span the tab button
or use the arrow keys
I think every site should have a way to navigate using only the keyboard
^ this
grrrr
ok
so i was using git with github on my laptop through git bash for windows
and it was all fine
it prompted me for github login details when i tried to push, and then it was fine
tried to use it on my desktop
it just doesn't ever ask for credentails
'The requested URL returned error: 403'
managed to get it working by generating a key using ssh-keygen
so it prompts for the secret when i try to push
come back about 20 mins later
same fucking thing
it doesnt ask for a passphrase, or to log in
or anything
it just gives up
ok os
so
in my github account
there is the key
in my .ssh folder, id_rsa.pub exists
but when i do git push, it just fucking gives up
doesn't ask for credentials, doesnt try to use the ssh key
again most of the tutorials/guides just go 'and now it works :D!!!'
i am trying to activate existing venv
but from a script
and i cannot access current shell
os.system and subprocess always open new subshell (sh) and execute commands there
how can i access current shell and execute commands within current shell?
what
as in through python?
oh i see
i think the issue is potentially that 'current shell' doesn't really exist
in the sense that the python program is what is running in the shell
yeah
so you can't have other stuff
take a look at #help-orange
ah yep
So i got that working
need a bit of advice
I want to host some large (>20mb) demo files for my application on github, but i don't want people who clone to have to download these as well
is there anywhere i can put them on the repo, maybe on a wiki somehow, where they are hosted but aren't part of the repo?
For pupy, make sure all the submodules were also cloned.
🔍
Couple of other things:
- Don't use
sudo. Either do a user install (pip install --user m2crypto) or make a virtual environment - Use Python 3 instead of 2. As you can see from the warnings, Python 2 will be EOL soon.
try using pip3
Well this is odd
got my earlier issue sorted
I made a change to readme.md in browser on github, and it turns out i only commited to the 0.1.0 release
firstly, it seems odd that you can commit to a tag/release in the first place
secondly, did i just accidentally 'enter' the tree for that tag, or am i going to keep accidentally doing this
anyone here good at pycharm?
Is there a way I can add a breakpoint for every line containing a specific variable?
I'm learning git
right place then
I'm going through the book on git's website and I'm trying to use cat .gitignore in this tutorial but it doesn't seem to be working right
what OS are you on?
the way it's shown the line should continue past like
<then I should be able to put stuff here>```
I'm on windows, using gitbash
windows 10 to be more precise
and which part of the book are you at? I'm assuming you're reading the Pro Git book online
right, I found the section
so cat doesn't do what you think it does
it's a program that stands for concatenate
what it does is it concatenates files and then prints the contents to standard output, which is usually your console/terminal
if you try cat file_with_words_in_it you'll see the contents of the file printed out
I know what concatenation is
okay let me try it
it just says "cat: file_with_words_in_it: no such file or directory
ah, I didn't mean for file_with_words_in_it to be taken literally, rather a text file that has words written in it
oh okay let me try it with a fiel that has words written in it 😅
okay i see
it printed out the contents of the file
so the section in the book says this:
Here is an example .gitignore file:
$ cat .gitignore
*.[oa]
*~
that's where I'm at
what it is showing is the output of cat .gitignore being run in the shell, which then outputs:
*.[oa]
*~
it's showing that the .gitignore file contains the lines
*.[oa]
*~
it then goes on to explain what the first and second line mean
That's odd it doesn't explain cat
it's a Unix command, the reason you have it on Windows is because of git bash
Is the book assuming previous knowledge then?
I don't think so
if you have any questions about Unix-like commands though, we have a #unix channel
I'm not sure if it works in git bash, but try man cat?
does that bring up the manual for cat?
nope
ah alright
thanks for the help
question regarding git
hello
if I make changes to my .py file, and it was already commited to git
when I do a git status, should it now show up?
if you saved the file and it is not ignored, yes
it's not showing up in my git status 😦
I'm getting a ``` modified: .gitignore
modified: .idea/workspace.xml
renamed: PyPDF.py -> Convert_to_text.py
new file: Pipfile
I did rename the file but that was a while ago
maybe I didn't commit the change or something?
If the change has already been committed then it wont be shown there
git status only shows uncommitted changes
I've made changes
it's just showing that I renamed the file
that was a while ago
since then I've made changes to the code
file_name meaning the new file?
file_name being whatever file you're talking about
well basically
no
it's not a new file
technically I started with one file, mistakenly delted the branch that it was saved to
recomitted
then changed file name
so my output is ``` modified: .gitignore
modified: .idea/workspace.xml
renamed: PyPDF.py -> Convert_to_text.py
new file: Pipfile
is it a new file? I don't know how to answer that
are you talking about this? renamed: PyPDF.py -> Convert_to_text.py
yes
what are you expecting to see?
well I made changes to the file
so I expect to see Convert_to_text.py
since I believe it should be in the staging area, because I made changes to it and want to commit
Yeah it should show up as unstaged
I mean I believe it's being tracked though, just don't know if the current iteration is being tracked
That doesn't make sense: a file is either tracked or it isn't
if you see the rename then the file is clearly being tracked
Renames and file changes will show up as a rename, not separately
could it be that I didn't commit the rename?
ELA is right but that is only once you've staged the changes
git status should be telling you which changes are staged and which aren't
my output to git status is ``` modified: .gitignore
modified: .idea/workspace.xml
renamed: PyPDF.py -> Convert_to_text.py
new file: Pipfile
That's it?
yes
You may have already staged the change
This is what it should look like
$ git status
On branch add-testing
Your branch is up to date with 'origin/add-testing'.
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
renamed: testing/object_attributes.py -> testing/asdf.py
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: testing/test_classifier.py
where are you running this?
oh ok one sec
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: .gitignore
modified: .idea/workspace.xml
renamed: PyPDF.py -> Convert_to_text.py
new file: Pipfile
that's my full git status
im running this in the terminal on my IDE
PyCharm
run git diff HEAD:PyPDF.py Convert_to_text.py
index f5b01ac..e3d4220 100644
--- a/PyPDF.py
+++ b/Convert_to_text.py
@@ -2,20 +2,30 @@
from PIL import Image
import pytesseract
import sys
-from pdf2image import convert_from_path
-import os
so are your changes there?
If yes, it means you have already staged the changes
and nothing is wrong
I mean I made changes in the code
I am asking if the diff is showing your changes
I can already see 2 imports have been removed
gah I have to pick up my mom >.<
any good opinionated formatter for pycharm?
@tawny temple yeah but im actually still using pdf2image import convert_from_path
as well as import os
So are you saying the diff you see is not correct/up to date?
what I'm saying is that the output says ```-from pdf2image import convert_from_path
-import os
which is not accurate
because I am actively using both of those modules in my code
Something is not adding up then
yeah
maybe I can just undo everything?
and save what;s current
*commit
this is my current import section
import pytesseract
import sys
from pdf2image import convert_from_path, convert_from_bytes
import os.path
import re
from collections import Counter```
Is there more to the diff?
diff --git a/PyPDF.py b/Convert_to_text.py
index f5b01ac..e3d4220 100644
--- a/PyPDF.py
+++ b/Convert_to_text.py
@@ -2,20 +2,30 @@
from PIL import Image
import pytesseract
import sys
-from pdf2image import convert_from_path
-import os
that's it?
that's the whole thing
I don't know what's wrong
I may have more than one headd?
head will just be the latest commit
its comparing the file from the latest commit to the staged file you currently have
You can try to commit it
I want to share this on github as well as back this up locally
You can commit then create a new branch from it
then push the branch and check online if the file is correct
I am suggesting a separate branch so you don't mess up the one you have online (well you can always force push but it's better to avoid that)
ok
so I tried to commit
Found a swap file by the name "~/PycharmProjects/OCR/.git/.COMMIT_EDITMSG.swp"
owned by: blah dated: Sat Jul 20 17:32:16 2019
file name: ~blah/PycharmProjects/OCR/.git/COMMIT_EDITMSG
modified: YES
user name: blah host name: blahs-MBP.home
process ID: 24227
While opening file "/Users/blah/PycharmProjects/OCR/.git/COMMIT_EDITMSG"
dated: Sun Aug 18 20:27:11 2019
NEWER than swap file!
-- More --
as you can tell
I am new to this
oh
like it's waiting for you to enter a commit message
I think that's why this happens
I kinda just kept hitting enter
cuz I was scrolling throught he messages
it basically said this is happening because a) someone is editing this already b)needs a name
and then I kept hitting enter and it's asking me for a name
so I'm going to write one
but before I do I'm going to save my code to a paste bin
incase for somereason I screwed mysel;f
I wonder which version will be committed
the most recent or changes or the one that I started
what are you checking the difference between?
uh oh
between git commits
do I override idk
I don't understand what's happening my goodness
I would suggest you just back up all your changes and try to scrap whatever commit you had currently
I mean the commit you had in progress
you mean the one tht's read only
I saved my code to a paste bin and emailed it to myself
do you have any commits you have not pushed?
how do I check that
alright I had to exit the git commit message section
[No write since last change]
going to check log now
omfg stressful
im still in it
it's a loop for gods sake
head is pointed to master
I had another head in there because I tried to make a new branch
and to be clear I haven't pushed anything yet, I've only been working locally
so you see something like (HEAD -> master, origin/master) on one commit?
🤔
3 commits
no I havent set up a remote
oh ok...
I've been working locally
I was thinking you could just clone from remote and apply your saved changes
So did you ever delete ~/PycharmProjects/OCR/.git/.COMMIT_EDITMSG.swp?
I don't think so
how would I delete that
it's just a file in a folder
you can use git rm ~/PycharmProjects/OCR/.git/.COMMIT_EDITMSG.swp probably
or just rm if you're using git bash
hmm
well it asks for a file
rm doesn't work, even though I'm on unix
so when I put in the full file path
does the file still exist?
didn't match any file
I guess that resolved itself then