Spyder: [Errno 2] No such file or directory - python

I want to run this code in Github : https://github.com/llazzaro/lsa_python
but I don't know how to execute it with nosetests. I have python 2.7.11 and anaconda 4.0.0, I have to run it with Spyder because I need scientific packages so when I put this link: https://github.com/llazzaro/lsa_python on Spyder I get this:
[C:\Anaconda2\python.exe: can't open file 'C:\Users\CLIENT\Desktop\lsa_python-master\sanstitre0.py': [Errno 2] No such file or directory]

Maybe you need to set your working directory correctly. It probably looks for the path from the current working directory.
You can change it here:

Little late to answer these questions But still if anyone facing the same issue this answer might help
I was facing the same issue. I even reinstall the anaconda. But it's still doing the same issue. Then I figure out something very silly.
First of all, you have to set your working directory
After that, you have to hit the Run button.
I was pressing ctrl + enter
But after setting the working directory for the first time you have to hit the run button then it will work
Hope it will help.

Related

How do I solve "pythoncom39.dll could not be located error"?

It has started appearing ever since I installed Anaconda on my PC. It doesn't affect anything and when I press "Ok" it goes away. But it is quite annoying and I would like to know the reason. It has only appeared when I try to run a development server in Django or try to install python modules using pip. Is there any way to solve this?
It happens because anacondaa3\Library\bin\ in this folder pythondicom39.dll has crashed you need to replace it with a new file
Yes, that dll file might be corrupted. Just replace, and then try it. You can download the pythoncom39.dll files from the following link
https://freeonlinestudies.com/python-dlls/

File permissions issue with python/Spyder/Anaconda after upgrading mac to Catalina

After upgrading macOS to Catalina, my Anaconda installation was helpfully reconfigured by Apple. Advice from the Anaconda website suggested a fresh install was the best way to go. Did that and all seemed good. I use spyder from the Anaconda navigator. But trying a previously running python code failed due to apparent file permission problems. For example,
file='/Users/stingay/Documents/Coaching/WAIS/2019:20/041019/Race Walk Test-2019-10-04T16.29.13.774-C5612E80FB1D-Accelerometer.csv'
with open(file,'rt') as f:
data = csv.reader(f)
next(data)
results in:
PermissionError: [Errno 1] Operation not permitted: '/Users/stingay/Documents/Coaching/WAIS/2019:20/041019/Race Walk Test-2019-10-04T16.29.13.774-C5612E80FB1D-Accelerometer.csv'
I can't see an issue with the permissions on the file or the directory structure in which the file sits. If I move the file to~/.spyder-py3 (the working directory), it works.
Looks like there is some extra python/spyder/anaconda permissions issue with the file/directory I can't spot. Any ideas?
I guess you have solved this by now, but for future reference, I still post my answer.
TLDR: I opened a file (from the folder causing the problem) directly in
the spyder editor (File | open). As a consequence, the editor should have triggered the pop-up dialog question whether you want to allow access or not. In my case, the mac silently granted python/spyder access to the folder. Now I can run the code in spyder without more problems than I have caused myself.
Longer version:
The source of your problem is described here:
https://www.howtogeek.com/443611/how-macos-catalinas-new-security-features-work/
Knowing that links are something frown upon, here's a summary:
The problem is that the folders "Documents" and "Downloads" folders nowadays are protected and you would need to go to the security & privacy settings and "Files and Folder,s" and allow the applications to access these. Unfortunately, spyder does not show up here. So, if you want to run your python program from the terminal, you should probably grant the terminal access to the folders.
Total noob here, but I might have stumbled upon a solution for people that have problems reading in their data in spyder after the Catalina update. I had the same problems you describe and got the same file permission errors.
I couldn't resolve the issue, reinstalled several times but didn't work for me. I couldn't use my Utorrent either, and while attempting to solve that problem I came across https://discuss.pixls.us/t/problems-with-darktable-and-mac-osx-catalina-solved-with-dt-2-6-3-1/14400/19 this forum.
Long story short, in the forum people couldn't really resolve the issue, but someone pointed out that if you just run the application from the terminal, it somehow works. I tried to do this with Spyder, and I seem to be able to use the read_csv('file') function again. So try opening the terminal, then type 'spyder' (without '') and press enter. Somehow all issues seem to be resolved. Hope this helps someone.
Same problem here. I re-installed Anaconda based on this link and Python is able to access folders where Catalina has added newly restricted security:
Install Anaconda following instructions below:
https://www.anaconda.com/how-to-restore-anaconda-after-macos-catalina-update/
For Anaconda-Jupyter user, you are good to go
For Commandline (Terminal) Python user, you are good to go
For Anaconda-Spyder user, two options as a workaround after installation above:
Avoid Mac default setup-folders and relocate files to /Users/[user_name]/..
OR
Launch Spyder through Terminal (execute "sudo spyder") under root user
Lastly, changing or reseting folder/file permission does not resolve permission issue. Despite of the security issue under the more restricted security folders, somehow Spyder-Python is able to open .py files in these folders.
Since Jupyter and commandline Python can access these folders, I assume there will be a fix in the future for Anaconda-Spyder.
My code didn't work at all after Catalina update. The simplest partial solution that I found was to copy all files containing the scripts in a new folder. That works at least to run the codes, but I still dealing with annoying message to allow access to my files.
conda update --all in terminal worked for me. It updated everything. I did have to go through the annoying messages for access to my files as well. but after clicking yes a hundred times it was ab

Jupyter Notebook error. No such file or directory C:.../HOME

I have installed Anaconda2, and today decided to update to Anaconda3. I installed Anaconda3 at the same time as I uninstalled Anaconda2.
Now, Jupyter Notebook shows this error and quits every time I try to start it.
The path in the error message is: "C:\Users\Hongyi\Documents\%HOME%"
What is causing Jupyter Notebook to quit?
Okay it looks like I found a solution.
Jupyter started running after I created the appropriate folder in the appropriate path.
In my case, it is creating a folder named %HOME% (with percent signs), in the path shown in the error message.
Now Jupyter is up and running.
Thank you guys for your thoughts and suggestions.
After readed this solution I tried another one (a comfortable one for me):
Open the location of the "Jupyter Notebook" shortcut (right click > More > File location) and right click again > Properties. In the Destination field (Sorry if the label is another ... the thing is that my Windows is in Spanish and I don't remember how it's labeled this field in English) just change the %HOME% at the end for a path to your "Work Folder" (if you have not created one then just create it). And this way It works also.

Error running .py from Windows 7 command prompt

I am new to python and I have just installed python 2.7.3 on Windows. I will also install django so I need to execute a file named ez_setup.py. I know it seems like an easy question and answer can be found in internet, but this is not the case. I tried lots of things and tried what internet says, the problem is still there and I cant find the problem!
I follow all the steps that is explained in tutorials in order for Python to work properly. (Installing steps and editing environment variables..)
Python's location is:
C:\Users\name\27
Command prompt starts like:
C:\Users\name>
I have put ez_setup.py file under both C:\Users\name\27 and C:\Users\name.
When I type "ez_setup.py" or "python ez_setup.py" or "\27 python ez_setup.py" and lot of combination, it says:
python: cant open file 'ez_setup.py': [Errno 2] No such file or directory.
What should I do? Where do I make mistake?
Just do:
python ez_setup.py
You need to say your machine that it should execute this .py file with python.

Python IDLE won´t start

I´m a noob in python and about a week ago IDLE stop working, I have readed some other people questions about this, but none of them had the same error that I´m getting, which is:
Traceback (most recent call last):
File "c:\python26\Lib\idlelib\idle.py", line 21, in <module>
idlelib.Pyshell.main()
File "C:\python26\Lib\idlelib\PyShll.py", line 1386, in main
root = Tk(className="Idle")
File "C:\python26\Lib\lib-tk\Tkinter.py", line 1643, in __init__
self.tk = _tkinter.creat(screenName, baseName, className, interactive, want
objects, useTk, sync, use)
_tkinter.TclError: Can´t find a usable init.tcl in the following directories:
C:/Python26/lib/tcl8.5 c:/lib/tcl8.5 c:/lib/tcl8.5 c:/library c:/library c:/
tcl8.5.2/library c:/tcl8.5.2/library
This probably means that Tcl wasn´t installed properly.
So I have reinstall python about 3 to 4 times and I keep getting the same error.
I´ll will for ever be in debt to anyone that gives me a solution to this error.
By the way, I´m running Python 2.6.6 on Win 7 32-Bit.
Thank you.
This TCL issue has appeared in a number of Python forums and is generally prevents the IDLE GUI from starting e.g. http://www.gossamer-threads.com/lists/python/python/902912 and is related to the TCL_LIBRARY enviroment variables. Try and edit the enviroment variables
Right click on (My) Computer, go to properties, Advanced Tab, press Environment Variables and edit TCL_LIBRARY to indicate the Python path e.g C:\Python26\tcl\tcl8.5 (or enter the path that represents your version. Idle should start then.
I noticed that this is an issue when you install other programs that may depend on the TCL Library. Happened to me after I installed SciLab. Therefore changing the variable may cause issues with another installed app.
Hope this helps.
Some folders may have been deleted or removed.
Go to Uninstall Program
Choose Python
Click "Change"
Then click "repair"
Allow the computer to repair....Should work after this.
Some notes*
Always make sure everything is in the same directory that you are working in CMD. I opened up my directory from the cmd and put my files in the same directory.
Check your 'App data' folder too for any Python files.
Be aware that 'App data' folder may be hidden.
Also when you reinstall click customize and python will allow you to make your own customize path location which is helpful and a lot more simple then what python chooses.
This could be caused by using the wrong version of Python.
32-bit and 64-bit work differently.
(Assuming your Python install is not corrupt. Did you make any changes to the Python install, try and install anything else?)
What is your Python install directory?
Look under Python_install_directory/tcl , init.tcl should be there, is it?
Tell us what you find.
Hey I don't know why this worked for me but I just right clicked on the the idle icon and clicked "Duplicate". This created another icon "IDLE duplicate", weirdly, and when I try to open this version it works. Hope this helps!

Categories