How to make an existing wxPython code run on Mac with conda? - python

I have an existing wxPython code which runs perfectly on linux and which i want to run on mac. I have the installation through anaconda on both linux and mac.
For mac, i am getting the error "This program needs access to the screen.Please run with a Framework build of python, and only when you are
logged in on the main display of your Mac."
I installed pythonw on through anaconda and I am able to run wx.APP() when running python through the location "/Users/vnigam200/anaconda/bin/pythonw".
I am not sure how to use this location for running my existing script. I tried shebang but it doesn't seem to work.

On Macs you need to run pythonw for wxPython scripts instead of the default, which is python. This is a known problem with Anaconda that they don't seem willing to fix:
https://groups.google.com/a/continuum.io/forum/#!searchin/anaconda/wxpython$20osx/anaconda/-ZAynUQW5HQ/L8AeqfMWNWwJ
https://groups.google.com/a/continuum.io/forum/#!searchin/anaconda/osx$20framework/anaconda/1rX3A1Noi9Q/68MNJWLxupYJ
So basically just do the following in Mac's terminal:
pythonw /path/to/your/script.py
Then it should work fine.

Related

Can't run any Python files on Ubuntu(WSL)

I have just started working on my new pc and just to get a feel for it I wanted first to start working on python files, so I started first by just wanting to run WSL on windows and it installed correctly but when I want to run any python using the run python file on the top right on VS code, this is what gets executed $ C:/Users/jaffe/AppData/Local/Microsoft/WindowsApps/python3.10.exe f:/Projects/hello.py
And this is the error: -bash: C:/Users/jaffe/AppData/Local/Microsoft/WindowsApps/python3.10.exe: No such file or directory
I have no idea what's causing it but when I run the file using 'Shift + Enter' which is: Python: Run Selection/Line in Python Terminal it seems to run the single line correctly but it gives me this error instead:
print("Hello, world")
-bash: syntax error near unexpected token `"Hello, world"'
but when I run it using python3 hello.py, it works perfectly fine?! I'm so lost as to why this is happening and how could I fix it.
Might be relevant: I'm using windows 10, installed python 3.10.2 from windows store, all of that is in VS code and the python code is one line: print("Hello, world") and I changed the permissions of Local/Microsoft/WindowsApps so it's now accessible by all users to view/read/edit/run, made sure that python3.10.exe exists(on the WindowsApps and it works perfectly) and reinstalled it many times, tired python3.9, and tried to install python from the website instead of the windows store and still the same, manually added python to PATH and tried .venv and didn't work. when I launch python3.10.exe outside vs code it seems to run perfectly, I have worked with python before and it used to work fine now I don't know what's wrong.
I have seen other questions of the same problem I'm having here but none of them solve the problem.
No such file or directory C:/Users/...
For wsl, the Windows filesystem is accessible, but it has a different path. It is mounted under the /mnt folder. So you would find your python .exe under /mnt/c/Users/jaffe/AppData/Local/Microsoft/WindowsApps/python3.10.exe. This said, the executable file is meant to work on Windows, and it doesn't really makes sense to use it on Linux when you could run python within your wsl distro.
python3 works perfectly fine
This is because most Linux distributions come with python3 pre-installed, so you can use it already. To see where it is located, you can run the command which python3, or python3 --version to check its version.
If you want to change version, you may consider download it from you package manager, apt.
I also suggest to install python3-pip if you don't have it already to get the pip package manager for python.
In my case when I ran into this.. I discovered pyenv. This allows you to download more than one version of python. You can then go into a specific directory, such as your python project and issue a python local 3.10.0 (for example). Here's a link on how to install it as well as poetry which is a virtual environment manager that is become very popular. You can also create an alias for python that works off of this. I add this command to my alias file and source it from my .bashrc. alias python='pyenv exec python3'

Windows Python 3.9, pip, vscode not working correctly tried every tutorial

I've gotten this to work relatively easy on my Mac I with django but for some reason Windows has been a heartache.
the problem is that in the console I can only get py to start executing python.
python and python3 do not work whatsoever
and also I can't get pip to install either because the py command won't execute it but python and python3 just open the windows store.
I've installed python to the path with the installer and I made the location of the file C:\Python\Python39
changed the hierarchy in the PATH in user variables and system variables to where python is at the top in both.
I've edited the vscode settings
I've also turned off the App execution aliases. That did nothing.
I'm at a complete loss so if any one has any advice I'd be so appreciative.
This tutorial helped me make pip working when I started programing
https://youtu.be/28eLP22SMTA

Run Python script as a Windows service on a non-Python PC

I am looking to run my new Python script as a service. The problem is the users most definitely would not have Python installed. After doing research I found the two main options: nssm and the win32serviceutil code, but as far as I understand both require a Python installation on the PC, since you have to specify the path to your python.exe.
Is there any other way to make a Python script to run as soon as Windows is started and run in the background, which doesn't require an existing Python installation?

Arrow up / previous command in VSCode Python Interactive not working

I'm working with VSCode on an Ubuntu 18.04 machine. Everything is fine except that I can't get back to the previous command in Python Interactive Window via Arrow Up. It works in the integrated terminal though, integrated shell is /bin/bash.
I have no idea where this is coming from. I changed "keyboard.dispatch" to "keyCode", but that's not the problem. I also tried different versions of the python-extension.
Do you have any idea?
Thanks!
Not sure if this is helpful for you as an Ubuntu user, but I came across the same problem in Windows this week. In my case, the issue cropped up after I installed the Python extension in VS Code (or at least I didn't notice the issue before this). The combination of using the Python extension, Git Bash for terminal, and python virtual environment killed the up arrow feature for me. Using python outside a virtual environment works fine. My solution was to use Command Prompt as the terminal when I wanted to use a virtual environment interactively.
In my situation, although I delete all the shortcuts of UpArrow, I still can get the previous command through UpArrow in Python interactive. This means there's no way to configure this shortcut, it was built in the plugin which built in Python extension.
So it's some problem with your Python extension, but you said you have tried to install a different version of Python extension but still not work. Make sure you have deleted it completely -> delete the extension folder manually(it's under C:\Users[UserName].vscode\extensions\ms-python.python-xxx).

Running wxPython module on Windows XP?

I am trying to run a Python project that uses the wxPython module but the problem is that I don't have any idea why isn't working.
I tried to run it on Windows 10 (School) and it runs fine but when I try to run it at home with my Windows XP it doesn't run. The main problem is that it doesn't say any problem, it just seems to run but it doesn't.
I am using Python 2.7 and I am not running the .exe file from the application I just run the .py file that executes everything. (I did in the same way in both Operating systems)
I have installed wxPython 4.0.2.
Is that I am missing something??
I am new in this, so pls don't be so hard!

Categories

Resources