Can someone help me figure out why terminal (MacOS) will no longer find python files I have saved? - python-3.x

So I'm new to learning python. I have python 3.8.2 installed on my MacBook Pro. It was working fine for a week, and I was creating code in atom, saving as .py files to a folder on my desktop. Terminal was locating and running those files easy. However, now when I go into terminal it does not see that any of my files are in the folder, just a hello.py which prints "Hello World" but I do not have any such file in that folder.
For more background, I believe the source of the error is from my earlier command. I was unsure of how to quickly navigate terminal, and as I was in a folder in a folder and wanted to leave the second folder, I thought it was similar to those old command games were you tell them to do something. So in my dumb head I typed "MacBook-Pro:FolderName user$ exit foldername" then clicked return. After this I got a message that I didn't save so I don't remember it but it was a few more lines and I believe it said it exited. I could no longer type in terminal. I closed the shell and opened a new one and thats what lead to my current issue and why I am here seeking help.
I have included a photo of my atom code, what terminal says now and my folder of files terminal can't find.
Edit: I cannot include pictures yet due to reputation being low so it has been changed to a link photo of issue here
EDIT: To add to this, I created a new save folder, moved one of the old files over to the new folder, and it ran normally. This leads me to believe that I used terminal to somehow ignore or forget that initial save folder and all its content. Is that a thing that can happen?

Based on your picture, it looks like the misconception is about how directories work in MacOS. In your terminal, you type cd ~/py4e; in Unix systems, ~ is your home directory, so you’re navigating to the py4e subdirectory under your home directory.
Then, however, you type cd ~/ex_04 (or something), which means you’re trying to navigate to the ex_04 subdirectory under your home directory. This isn’t what you want; you want to navigate to ex_04 under the py4e directory.
In the Terminal, when you’re working in a current folder, you can change to another folder within that current directory by just typing the name of that subdirectory, i.e. cd ex_04 once you have run cd ~/py4e.
If you’re just starting out with the command line in MacOS, I would definitely recommend looking up some beginner tutorials online so you can get a better feel of navigating and working in the Terminal.

Related

Cannot access files within launched crouton but can from within chroot?

I recently updated a chroot on an old Chromebook from Ubuntu bionic to focal. The chroot has encryption enabled.
I usually work with Git repositories and other files within the Chrome's Downloads folder and haven't had any issues with this previously.
Since the update though, I found I was unable to run things like git clone -- I get an error saying cannot create worktree dir: no such file found. I looked around and found people had similar problems but there's been no clear solution.
Then I decided to look inside one of the existing folders within Downloads and noticed a problem there...
I can open a repo within my Downloads folder on ChromeOS and see all files as I used to.
I can enter-chroot and run ls on the same folder and see all files as I used to there too.
But when I launch the chroot/crouton (I used xfce4), and try to ls the folder from within the terminal, or even look at the folder contents from a UI window, the contents of the repo look encrypted -- as in all the filenames have changed to strings of equal-length and apparently random characters.
It's almost as if encryption is working in reverse -- so my files are unencrypted outside the crouton, but as soon as I go into the xfce UI, they're encrypted and there's no decryption happening. But that's speculation on my part...
Any ideas as to what is going on here? And how I can continue to work within crouton?
It seems this is to do with the fact that Chrome OS encrypts files and that something had happened since I updated Crouton (rather than my updating Ubuntu from Bionic to Focal).
I realised this was a bigger issue when even command line tools like tar and git (which I'd installed) weren't working.
When I tried to unpack a download of Firefox with tar xjf I got an error saying "Required key not available". Some searching around that led me to issue #3261 on the Crouton Github repo.
The solution for me was:
Ensure /etc/pam.d/su-l was writable. (I did ls -l /etc/pam.d/su-l to check but ultimately used sudo...)
Edit the file /etc/pam.d/su-l. (I used sudo vi /etc/pam.d/su-l to ensure the file wasn't read-only in that instant, and because I had no other text editor options but vi available.)
Comment out the line session optional pam_keyinit.so force revoke. (So it should read # session optional pam_keyinit.so force revoke.
Save the file.
Restart the chroot.

No Python Folder in " Documents "?

im trying to learn python from a video. The first step is to install and to go to Documents/Python where he has a bunch of files. I do not however have that folder. Cant find it on google so far either. Any help would be appreciated. Thank you so much.
https://youtu.be/myFD0np9eys?t=219 <-- Video
You don't have that folder because that's a folder he created to put all of his python programs (that he has already made) into. Please watch further into the video and/or watch the video more closely. He is simply showing you how to navigate your computer using the Command Prompt by using the cd command.
In the video, he changes the current working directory using cd. In his case, all of the python files that show up are the ones he has personally created in his Documents folder. You simply just have to navigate to wherever you save the python files you want to run. For example, if you have a folder on your desktop called "PythonProjects" and within that folder you have a python script titled "foo.py," you would type in the command prompt / terminal:
cd Desktop/PythonProjects
Then to run the file:
python foo.py
Maybe you can try searching for cmd commands to search for the folder, plus there's not really any reason to open the Python folder as you can save all your work in a new folder in the desktop if you make one
In the video he has put all of his python programs and modules in a folder called Documents , hence he is getting the list of files , not necessary that you would have those files in the first place as he has downloaded a lot of packages , you might have a default location which is generally.
C:\Users\username\Appdata\Local\programs\python\python38-32
And not one more thing the python38-32 in the location i specifeid is my python version (python 3.8) if urs is python 3.7 you may want to enter python37-32 instead . Hope this answer helps you .

Adding a permanent value to $PATH on Raspbian

I am quite new to Linux so I'm sorry for my newbie question,
but for about and hour now I'm trying to add Node.js to $PATH with no luck :(
I've used the following line to add Node
PATH=$PATH:node-v0.10.24-linux-arm-armv6j-vfp-hard/bin
it worked, but when I logged off the terminal and logged in again, the path disappeared.
Later I tried adding the same line to .profile , .logins.defs and .bashrc.
All didn't work so I removed the line.
Please help me with this!
P.S , when I added the line to .profile I was able to call Node, but when I changed my directory in order to navigate to a Node project directory, I received the following error:
-bash: node-v0.10.24-linux-arm-armv6j-vfp-hard/bin/node: No such file or directory
You should add an absolute path, not a relative one. You added this to your path: node-v0.10.24-linux-arm-armv6j-vfp-hard/bin. That's a relative path, not an absolute one (absolute paths start with a /). You can change your line to:
PATH=$PATH:DIR/node-v0.10.24-linux-arm-armv6j-vfp-hard/bin
where DIR is the full path of the directory containing node-v0.10.24-linux-arm-armv6j-vfp-hard.
It's probably a good idea for you to read a bit on how this all works - it's not that complicated once you see it explained. See https://superuser.com/questions/238987/how-does-unix-search-for-executable-files for an example.
You have $HOME already set to your home directory.
So you can use this in your .profile:
PATH="$PATH:$HOME:$HOME/bin:$HOME/node-v0.10.24-linux-arm-ar‌​mv6j-vfp-hard/bin"
If you set it as an absolute path you will not be able to copy that .profile to another user who is set up similarly.
I see there is another question that deals with installing node.js on Debian - and must admit I am surprised it is installed per-user. So if you do the install for another login you might want to copy your .profile to the new login to solve this same issue. There would be no per-user editing required if you use the $HOME variable like this. Just a simple copy or cut and paste.
For reference, here is that other question/answer: install node.js on debian

Setting Working Directory to Desktop in Cygwin

The current directory on cygwin is home/myuser. I navigated to cygwin and found it has a directory called home/myuser and could not figure out how I would navigate to the desktop. I did not want to add a desktop directory there and I could not navigate above the root folder (cygwin). Any idea on how I could do this?
This is essentially covered in the Cygwin FAQ under "How can I access other drives?". No, you're not trying to access another drive, but you are trying to access a folder outside of the Cygwin tree. As the FAQ item says, Cygwin maps your Windows drives as /cygdrive/<drive-letter>, so your desktop is likely something like /cygdrive/c/Users/<username>/Desktop. Note that the path has changed over the years with various versions of Windows and you didn't specify what version you're running, so it may not be exactly that.
Anyway, what I would do, would be to create a symbolic link to that from my Cygwin home folder. Something like this:
ln -s "/cygdrive/c/Users/<username>/Desktop" Desktop
I put the quotes in because depending on what version of windows you have, this path may include spaces.
You'll probably notice from the FAQ that the Cygwin version of bash accepts DOS-style pathnames, so you can actually do the following:
cd "C:/Users/<username>/Desktop"
But I recommend avoiding such syntax. Not all Cygwin apps understand DOS-style paths, and you'll only end up confusing yourself if you have to try to figure out whether what you're doing will work with a DOS-style path or not. It's best to just use the Unix-style paths for everything when in the Cygwin environment, unless you have a very good reason not to.
Add
cd "/cygdrive/c/Users/<username>/Desktop"
to .bashrc file located in <cygwin install directory>/home/<username>. This will change working directory to desktop every time you open Cygwin terminal.

sublime text 3 sidebar autoupdating not working

I was wondering if anyone could tell me how to make it so that sublime text 3 automatically updates the sidebar when i add a new folder/file to the current project in finder (osx).
Right now, I have to manually go to Project -> Refresh Folders
My user preferences are probably not the issue as they are very basic:
{
"color_scheme": "Packages/Color Scheme - Default/Solarized (Light).tmTheme",
"font_size": 18,
"tab_size": 2,
"translate_tabs_to_spaces": true
}
If anyone could help that would be great as I have tried googling, searching for an answer to this but havent found anything that works.
Thanks in advance.
I recently began experiencing this issue and it turned out to be DropBox related. Once I removed DropBox and restarted my machine the folder refreshing began working as before. Also, DropBox was affecting several other apps, specifically SourceTree and Transmit as well as Sublime Text 3.
I had this same issue. You could always bind the folder refresh to a hotkey. While this is not a complete fix for auto-updating, it still saves you from a more lengthy manual refresh. I believe this is how Dreamweaver works as well.
I had the same issue with ST3 (OSX 10.9.2). It was something wrong with the root folder of my projects. I created new folder Code1, moved all of my projects there, removed old Code folder and renamed new Code1 to Code. This bit of magic returned things back to normal.
Open the console and see if there are any errors. It logs when there are changes to the filesystem.
I've had this problem when I used disks that where mounted with samba. My best guess is that this has something to do with the OS or filesystem not triggering the correct events for sublime to realize that there's new stuff in the folders.
I'm guessing that the disk on which the project you're working on belongs to a mounted disk, that might have a different filesystem. Try moving the project and see if that helps. If that is the case maybe you ought to see over which flags and stuff you're using when mounting the disk on which the project was originally stored.
How you would go about fixing that however I have no clue about since I don't have any experience with OSX.
This could be the result of an error with the plugin SidebarEnhancements, as was the case for me. Using package control I removed the plugin. I couldn't package install the plugin back as it would not show up on the list of available plugins. So instead I followed this github issue in the repo and got it cloned into the correct directory.
Another side note, in sublime I clicked "Sublime Text" -> "Preferences" -> "Browse Packages". to open up the correct location to clone the repo in finder. If you click on the folder icon in the top bar of the resulting finder window you can actually drag this into iTerm2 so that you are in the proper location before running the git clone command included below.
git clone https://github.com/titoBouzout/SideBarEnhancements.git "SideBarEnhancements"
cd "SideBarEnhancements"
Finally, quit ST3 and reopen worked for me. Hope this helps.
I'm using Windows, so not sure if my solution is relevant to the exact question, but since I found this on Google, I figured it might just help somebody. My problem was specifically with the SideBarEnhancements plugin.
The dumb solution (try this first):
Close Sublime Text, go to the Packages directory (in Windows that's in %HOMEDRIVE%%HOMEPATH%\AppData\Roaming\Sublime Text 3 (Win+R, paste that path, enter);
Rename SideBarEnhancements to something else and then back to its original name;
Reopen Sublime Text.
The nice solution (for Git Bash on Windows):
IF the dumb solution has not worked, there is no point in following on.
However, if it worked, you can automate the process.
Open %HOMEDRIVE%%HOMEPATH%\.bashrc, or in other words: User\.bashrc (create the file if you don't have it);
Paste the following at the end of the file (preferably on a new line):
touchme() {
echo 'Killing Sublime Text process..';
taskkill -IM "sublime_text.exe";
cd ~/AppData/Roaming/Sublime\ Text\ 3/Packages;
touch SideBarEnhancements;
echo 'SideBarEnhancements folder touched;';
echo 'Returning to original directory..';
cd -;
echo 'Reopening Sublime Text..';
"/L/Program Files/Sublime Text 3/sublime_text.exe"&
}
Change the path to your sublime_text.exe (last line of the function);
If Git Bash is opened, execute source ~/.bashrc and go to 6;
If Git Bash is not opened, open it and go to 6;
Execute touchme without any brackets;
In case you use the touchme command for something else, or simply don't like it, feel completely free to rename the function (I just found it the easiest to write and remember :P).
I guess the code above can be adapted for Unix systems, too, with some small tweaks.
I had this problem after reinstalling Sublime Text 2 and symlinking.
A workaround I found was binding the refresh_folder_list command with cmd+s, since that's usually when we see the sidebar updating.
For this to work you'll need to install run_multiple_commands plugin.
Then you'll have to update your User Keymap telling it to refresh folder list every time you save. The syntax is fairly simple.
I also ran across Synced Side Bar after fixing the issue. I am not sure if this is a solution but sounds promising.
Hope this helps.
I don't have a solution but a theory on why this is happening. I noticed as well recently that it stopped refreshing. I've also noticed that when I use the finder to open folders or use the 'open' within any program, the OS would just show an empty directory when I know there are files in it. I would then have to select a few different folders to get it to recognize that I'm asking it to show me the contents in the folder. It's almost like that function is asleep and I have to nudge it awake.
It seems Mavericks is using some strong sleep agent and turning off any functions behind the scene that's not needed and perhaps it's also affecting the sidebar refresh.
Same issue for me with ST2 on OSX 10.7.5. I started by opening Finder to the folder where I had the issue and navigated to that folder in terminal as well. Then:
Create a blank file and observe if Finder refreshed.
echo "" > test.txt
If Finder didn't refresh, navigate to the parent folder in both Finder and terminal. Repeat step 1.
If Finder did refresh, rename the child folder you came from to anything and then back to the original name.
mv folder_name new_folder_name
mv new_folder_name folder_name
Auto refresh in Finder started working again as well as the Sublime sidebar for that folder and all child folders.
I don't have an explanation as to why this issue started. Prior to this solution, I attempted the following trying to figure it out. I don't know if these steps were necessary in resolving this issue.
I removed .DS_Store files from the folders with this issue.
Remove the Finder preferences file and restart Finder. As described here.
rm ~/Library/Preferences/com.apple.finder.plist ; killall Finder
Exit Dropbox
Thanks to #peresleguine for the suggestion of renaming the folder.
I had the same issue with folders and files not showing up. No matter what folders I added it wouldn't work, refreshing folders didn't work, if I restarted Sublime, I would then see the folders I added but none of it's contents. I ended up going to File -> Close Window and then File -> New Window, after that when I added folders to the new window, it started working again. Seems like it's a corruption in the project file somehow. Anyways hope this helps someone.
Mac OSX Mavericks
Sublime 3 Build 3059
If you're using OS X with python version higher than 2.7.1, try downgrading python to 2.7. This fixed multiple issues for me:
brew update
brew install pyenv
echo 'if which pyenv > /dev/null; then eval "$(pyenv init -)"; fi' >> ~/.bashrc
source ~/.bashrc
pyenv install 2.7
pyenv global 2.7
# now restart ST3
One of the sub-folders of my project contained a symlink to the project itself, making a loop. As soon as I've removed it and re-opened the project, the problem went away. However, that symlink was necessary for my project to function, so I created a simple .sublime-project file:
{
"folders": [{
"path": "/",
"folder_exclude_patterns": ["symlink-or-one-of-its-parents"]
}]
}
The exclusion pattern made Sublime ignore the loop, and the sidebar went back to normal right away. Just note that folder_exclude_patterns accepts folder names, not paths. That means that it might exclude something you didn't want to exclude (i.e. if you write lib it'll exclude all lib folders in your project, regardless of where they are). Hope this helps somebody.
I had this issue after symlinking my project files to another partition on the hard disk. I fixed it by editing the path for each project from Project > Edit Project to the new location.
A bit late to the conversation, but I resolved this by turning off DropBox's Finder integration. There is a known issue with Yosemite 10.10.x
https://www.dropbox.com/help/7144
Click on the dropbox icon in your tool bar, click the gear and then open preferences. Un-check Enable Finder integration. Then restart your computer.
Hope that helps.
I just fixed this issue and I think the reason is because I use dropbox to sync my ST3 settings.
Somedays before I restarted with 'reopen windows when logging back in', and found sublime opened earlier than dropbox finished its initialisation, which caused some settings couldn't load properly.
The result was when I used subl . to open project, I found the side bar not working properly. At the first beginning, I just closed ST3 windows and re-run subl, but it didn't work.
Finally I quitted ST3 (cmd+q), and made sure dropbox was properly loaded, then subl again. This time it worked.
Hope it helps.

Resources