Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pyrogram doesn't run when executing scripts outside the current directory #41

Closed
Onefivefournine opened this issue Mar 26, 2018 · 6 comments

Comments

@Onefivefournine
Copy link

Onefivefournine commented Mar 26, 2018

For example I have some boilerplate code with client initiation in a folder named MyFancyPythonModule, also I have config.ini in that folder, so that

root
- MyFancyPythonModule
- - app.py
- - config.ini

If I run it from root (./MyFancyPythonModule/app.py) it fails to initiate because there are no config.ini in root, but it tries to take it in client.py line 725
I suppose it's better to use something like os.path.join(os.path.dirname(__file__), 'config.ini'), or even make it configurable(passing a file path to read configs)

@delivrance
Copy link
Member

Hi, don't name your project folder pyrogram in the first place, as it can cause some weird issues.
Rename it to something else and let me know if the problem persists.

@Onefivefournine
Copy link
Author

Onefivefournine commented Mar 26, 2018

@delivrance Well, I already use other name, just took it here as example
P.S. Issue updated 'pyrogram' => 'MyFancyPythonModule'

@delivrance
Copy link
Member

@Onefivefournine Good, this is indeed some unwanted behaviour. Instead of __file__ you probably want to look at sys.argv to extract the correct dir. Want to open a PR?

@Onefivefournine
Copy link
Author

@delivrance Unfortunatetly, I'm not so good at python, so take it as a wish 😄
Also it would be great to have a configuration option of session file placement, because it has the same issue - it creates in execution root

@delivrance
Copy link
Member

@Onefivefournine Noted. There is actually #4 open for that, but I'm still unsure how to make it nicer (without messing too much with Client parameters).

Regarding this issue, I'm labeling it as enhancement.

@delivrance delivrance changed the title "TypeError: 'NoneType' object is not subscriptable" when calling script from other folder Pyrogram doesn't run when executing scripts outside the current directory Mar 26, 2018
@delivrance
Copy link
Member

As a temporary workaround for this you can use the api_key parameter instead: https://docs.pyrogram.ml/start/ProjectSetup#configuration
There is also a proxy parameter as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants