When I do image processing in pycharm, I can't add images from my file explorer in the directory. How should I fix it?
I've done what I can as possible but I'm a starter of python. I wasn't able to solve this. So, I know this's not enough by myself.
Since you're using pycharm you must have created a project folder in a directory
That directory is located at C:\Users<user>\PycharmProjects if you have done default installation this will be visible in file explorer and you could use normal copy paste then
I've been stuck for hours trying to figure out how I can get Pyinstaller to include images. I've made a small tkinter script which load up some images to display. The program works on my own pc, but I want to be able to download the script on another computer and run it with the pictures working, but I can't figure out how to do that.
I thought I could fix this issue by downloading a folder with the images on another machine and make the script refer to that folder but somehow it's just not working. It works when I run it on my own machine but not when I make it a .exe file with Pyinstaller.
os.chdir(sys.path[0])
path = os.path.dirname(os.path.abspath(__file__)) + r"\pics"
The thought behind the two lines above was that if I download the script on another computer as well as the pictures and insert them into a folder, I could refer to that folder and load them up (as long as the folder is in the same directory as my script) - but this isn't working. I'm clearly overseeing something, please help.
The easiest way is to use the Tree class available in a spec file. See https://pyinstaller.readthedocs.io/en/stable/advanced-topics.html#the-tree-class for the official documentation and https://stackoverflow.com/a/20677118/10475068 for an example of how to use it.
I am very new to this and struggling with the basics. I have a csv file /home/emily/Downloads/Roger-Federer.csv The textbook says that I need to "extract the file and download it to my current directory" on JupyterLab (I am using Python). What does this mean? How do I do this? Thank you
Every running program, including JupyterLab, has a "working directory" which is where it thinks it is on your computer's file system. What exactly this directory is usually depends on how you launched it (e.g., when you run a program from terminal, its working directory is initially the folder your terminal was in when you ran the command, but it's possible for a program to change its own working directory later).
Your file path indicates you're on Linux, so I'd suggest opening a terminal in your JupyterLab and running pwd to have it print out its current directory. (You can also run !pwd in any open notebook if that's easier.) You should then copy your CSV file to that directory.
If you do that, then from your Python code, you can just open the file locally, like open('Roger-Federer.csv') or pandas.read_csv('Roger-Federer.csv'). You don't have to move the file to open it from Python, though, you can just give it the entire file path, like open('/home/emily/Downloads/Roger-Federer.csv'), and that'll work just fine too.
I installed Spyder using Anaconda, and I am able to launch the IDE using the Spyder icon in my start menu (Win10). I wanted to set my preferences to open all .py files with Spyder, so I followed the Spyder start menu button to an executable, pythonw.exe. The problem is that I cannot launch pythonw.exe by clicking it.
How does the start menu icon for Spyder, which points to pythonw.exe, launch Spyder, but clicking the executable does not yield the same results? Also, when I double click spyder.exe in Anaconda\Scripts a command prompt opens along with the IDE, which does not happen when I click the start menu icon.
Why does this application behave so much differently than any other application I've used before (if this is just how things are in python, I apologize as I'm new!) and is it possible to set Spyder as the default application to open .py files in the same way I can open source files with IDEs in other languages?
Cheers
I found the answer in this question, answer by xyzjayne.
You create a bat file with the following contents:
start YOURPATH\Anaconda2\pythonw.exe YOURPATH\Anaconda2\cwp.py YOURPATH\Anaconda2 "YOURPATH/Anaconda2/pythonw.exe" "YOURPATH/Anaconda2/Scripts/spyder-script.py" %1
YOURPATH will be the path leading to the folder just above the Anaconda folder. For me it was:
C:\ProgramData
And you select the Choose default program to open this file... - and you choose that bat file.
When you go to Spyder shortcut's properties, the target includes a few files. So my guess is that for Spyder to run, all of these files must be run, and that's why when you just point .py files to one exe it doesn't work.
You can right click any of your *.py file, go to properties and choose Spyder as "Opens with" choice.
Right click on your file, and select open with or Choose default program to open this file.. and then in your system... select .. \Anaconda3\Scripts\spyder.exe .
I have also provided you the screenshot of the above path in my system for your reference.
In Windows 10 Anaconda installs itself into a hidden folder called ".anaconda" which is placed in the Users directory under your own profile sub directory.
When you first try to use the right-click menue "Open with" it opens up in C:\Program Files so you have to go up one folder and down into Users. You may need to have previously set one of the options in the View Menu of the file manager so that you can see hidden files. You can't do this from the "right-click open with" place, you have to set that in the regular file manager.
You will find a file called Spyder.bat a couple of folders down within that, e.g. C:\Users\Your_profile.anaconda\navigator\scripts
It will take forever to open each time.
for Anaconda3 on win11:
start YOURPATH\Anaconda3\pythonw.exe YOURPATH\Anaconda3\cwp.py YOURPATH\Anaconda3\ "YOURPATH\Anaconda3\pythonw.exe" "YOURPATH\Anaconda3\Scripts\spyder-script.py" %1
Below a baby-step guide to make Spyder your default program to open .py, including an icon!
First, search for Spyder in windows, and open the folder that contains spyder. Spyder will be a short-cut file. Right-click the spyder shortcut file and choose "Properties". Copy all the contents of the "target" content.
Open a Notepad. Write the word start and the paste the contents you obtained in step 1. Now, save the file as .bat, with any name you want, let's say "myspyderlauncher.bat", in a convenient location for you.
Go to any .py file, and choose "open with", and look for your .bat file (following the example above, the "myspyderlauncher.bat" file). Choose "always" to always open .py files with your bat.
Now double click the .py file and Spyder will automatically be started. VoilĂ !
Did you say you want a nice spyder icon too instead of that ugly white icon? Here are the next steps (optional):
Download Bat to exe converter (not worries, you will not need to install the software): https://web.archive.org/web/20190304134631/http://www.f2ko.de/en/b2e.php
Unzip the Bat_To_Exe_Converter.zip and go to the "portable" folder and run the .exe file. Open your .bat file ("myspyderlauncher.bat" in the example above), and then go to the right menu, click and look in the "icon" option and look for the Spyder icon (.ico file), which is normally in ...\Anaconda#\Scripts.
Now press "convert" in Bat_to_Exe and save your new .exe file in a convenient location with a convenient name you want. (Let's say we call it "spyderlauncher.exe")
Go to any .py file, and choose "open with", and look now for your .exe file (following the example above, the "spyderlauncher.exe" file). Choose always to always open .py files with your bat.
You will see that all your .py files are now associated to spyder, with a beautiful icon attached, and opening in Spyder.
Some screenshots below
I am struggling with our company's profile space which is limited to 250 MB for profile. I use PyCharm for some python project, but the problem is that PyCharm creates folder outside My Documents in:
C:\Users\Me\.PyCharmCE2017.3\
I would like to move the folder to some other location which is not synced with the server or to My Documents, where space is unlimited. Is there any way to change the location of the main Pycharm folder? I was looking for it in Pycharm settings but I couldn't find the option. Thanks!
Solution thanks to Rawing:
mklink /D "C:\Users\Me\.PyCharmCE2017.3" "C:\Folder\.PyCharmCE2017.3"
used from Windows command line. First you have to move original folder to your directory, here C:\Folder\ and then create a link with this command. No shared space problem anymore and Pycharm works perfectly fine! Thanks!