I'm running EPD and using IDLE for most of my coding. What I'd like to do is get IDLE to run a script to customize my environment whenever I restart the Python shell. I've tried reading all the various posts on customizing IDLE and the Python environment, and I've yet to see anything that addresses this specific scenario. Does IDLE or EPD IDLE (if there's any difference) have a particular module it's looking for when it restarts the shell, like usercustomize.py or sitecustomize.py? Has anyone accomplished this on their own? Any guidance is appreciated.
Upon startup with the -s option, IDLE will execute the file referenced by the environment variables IDLESTARTUP or PYTHONSTARTUP.
Check out: http://docs.python.org/library/idle.html#startup
Cheers,
Johannes
Related
I am having a hard time activating virtual environment, after I have created it.
The thing is, that when I try to activate virtual environment in command line, it works -
virtualenvironmentname\Scripts\activate
But when I try to run the same command in Atom, (I am using the Terminus package in order to be able to run the terminal inside Atom) I get this message -
File (path\activate.ps1) cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies
at https:/go.microsoft.com/fwlink/?LinkID=135170.
I was trying to run it by using slightly different commands such as -
activate virtualenvironmentname or activate (virtualenvironmentname)
, but it did not work.
I was further investigating a little more and I have found some clues, that I might need to change some script execution policies, but I am little bit afraid to do so, because I do not want to mess up my computer since I am just a beginner when it comes to system configuration.
Could anybody please tell me, how could I fix this problem? It would be really convenient for me to be able to run the virtual environment from Atom, since I will be writing my Python and Django lines of code there.
Thank You very much and I hope, that my description of the problem was somehow understandable.
I've been struggling for a long time now to get this running but I just couldn't do it. I am runnning PyCharm Professional on Win10 and I want to code and run Shell scripts, but I cannot get it to work. There is this Shell Plugin from Pycharm but there is just not enough documention for me to understand how it has to be setup.
How do I have to setup PyCharm in order to Run/Debug Shell scripts?
I tried changing the shell used by the Terminal to the WSL Ubuntu shell, which actually worked. Thus I can now manually execute the bash script via the terminal.
I also tried changing the Run/Debug configuration.
changed Run/Debug configuration
as suggesteed, changing the interpreter to bash.exe led to an error message.
interpreter changed to bash.exe
I tried bash.exe, ubuntu.exe and cmd.exe as shells for terminal, all of which threw a file not found error. As before executing it manually with the wsl path format(/mnt/c/..) works. manual execution
"file not found"-error
So I guess it was my misunderstanding in the end, that you can't really work with shell scripts like you do with python. meaning debugging etc and watching variables. I am trying to reduce my file shuffling code in bash anyways and try to stay mainly in python so there is now another motivation for that. thank you very much for helping me though.
I upgraded to Catalina today, which required updating BBEdit as well. Now I am having trouble using my virtual environment, specifically the debugger in BBEdit.
I installed python3 in a virtual environment via Homebrew, set the correct path, and can access the virtualenv correctly via:
cd /Users/joecat/venvjc
source /Users/joecat/venvjc/bin/activate
I used pip3 to install modules needed
I am trying to run this test script:
#!/Users/joecat/venvjc/bin/python3
import pandas
print('hi')
The pandas module is only in the virtual environment so it should work. If I "Run in Terminal" through BBEdit, the code executes:
But when I try to run in debugger via Command+D, the code executes without the "pdb" debugger popping up at all:
Then, if I adjust the first line to be a "fake" path (assuming this just skips it) it correctly opens up the debugger, and pandas can't be imported because it's no longer using the virtualenv, which is correct:
#!/Users/joecat/venvdddddjc/bin/python3
import pandas
print('hi')
What am I doing wrong with respect to changes to Catalina/BBEdit? I switched to using zsh over bash... is that part of the problem? I am a newbie and happy to provide more details if needed. Thanks for any help anyone can provide.
There have been a lot of changes over time to how BBEdit interacts with the shell environment. As of 13.0.4, BBEdit will run your login shell to capture its environment, whenever you run a #! script. But there are special cases for Python, Ruby, and Perl, since those all have built-in support in BBEdit.
One thing to be aware of: if you've switched to zsh from bash, a common practice is to copy your bash environment from .bash_profile to .zshrc. This won't work correctly in BBEdit, because the shell that BBEdit runs is not an interactive shell.
For that reason, you should set up the majority (and perhaps all) of your zsh environment by putting the declarations (PATH, etc) in either .zprofile or .zshenv (but not both). Any interactive stuff can remain in .zshrc.
(And if you're still stuck, writing to support#barebones.com is always a good idea.)
(p.s. I would not recommend using any BBEdit version older than 13.0.4 on Catalina.)
I was able to correct the issue by downgrading to BBEdit 12.1.16, the earliest release that works with Catalina, as opposed to the latest version 13.0.2 that I was using.
This may be a bug in BBEdit, or else there's something else that changed this functionality between 12 and 13.
Would love to learn more if anyone has any information on this issue. Google is turning up next to nothing on this problem
In case it is helpful to anyone who comes across this issue, I was able to resolve this by importing and setting trace on the pdb module in lines 2 and 3 (right after the virtual environment path set on line 1):
import pdb
pdb.set_trace()
This allows the debugger to run normally in BBEdit 14.1.2, macOS Monterey 12.3.1.
No idea what the underlying issue is. I guess pdb is naturally imported when using the native OS python, but must be manually imported when using a virtual environment.
Hope this helps.
For some reason my python shell is not restarting when I run a module. I feel like I've tried everything. I have opened, and created new files through the shell. I have reinstalled python. I have restarted my machine. etc. etc.
The shell does work when I write a function directly into it, so it's not a problem with the shell itself. When I "run module" in a .py file, it toggles to the shell but it doesn't have the "restart" message as it did before. So, running functions in .py files obviously doesn't work...
Has anyone else experienced this? Any ideas?
I'm using the python 3.4.6 shell for windows 64 bit...I was using 3.4.3 before but I thought upgrading might help.
Thanks in advance
I have personally never experienced this, however, if this has been happening AS SOON AS you upgraded to the 3.4.6 python shell, the existing scripts may be affecting the .py scripts used to run the python shell. I don't know if this helps but maybe go back to 3.4.3 or download the 3.6.4 version of python.
https://www.python.org/downloads/
I've been developing a set of scripts in PyCharm using C:/Python27/python.exe interpreter...
I'm creating a batch file and then running all of the scripts through this file from the cmd shell however the shell is not recognizing most modules because it is using the wrong interpreter (path for anaconda instead)...
How do I change the shell to use the C:/Python27/python.exe interpreter as default all the time instead?
I've tried looking this up but it all points to just adding the interpreter path, which I have... but the shell still uses the anaconda interpreter.
Any help appreicated
Take a look at : https://docs.python.org/3.3/using/windows.html#shebang-lines
Shebang lines at the beginning of scripts tells how a script should be executed.
Found a solution to my problem...
I needed to use:
set path=%path%;C:\Python27
This switched interpreter.
Cheers