I cant run the server in my project with django - python-3.x

I created a project in django normally, but when I try to run the server (python manager.py runserver) I get the following error: C:\Users\Fredy\AppData\Local\Programs\Python\Python39\python.exe: can't open file 'C:\Downloads\django_one\manager.py': [Errno 2] No such file or directory
The strange thing is that the manager.py file is there. I went back to other projects that I had already created that were working and the same error occurred.
Does anyone know how I fix this?

use "python manage.py runserver". If you look at the files, it has a "manage.py" and not "manager.py"

Usually this happens because you are not in the root directory of the project. Judging by the screenshot it looks like you are, but worth a double check.
There are a few possible solutions:
chmod +x manage.py (manage.py may have lost execute permissions)
Did you forget to activate the virtual environment?
Your installation of Django may not support Python 3.9 (Django 3.2 supports Python versions 3.6, 3.7, 3.8, 3.9, 3.10)
Some sources to look into:
python: can't open file 'manage.py': [Errno 2] No such file or directory
https://www.pythonanywhere.com/forums/topic/756/
https://docs.djangoproject.com/en/3.2/ref/django-admin/
https://docs.djangoproject.com/en/3.2/faq/install/
I hope this gives some direction. Good Luck

Related

IBM-federated-learning-lib_ModuleNotFound: No module named 'examples.constants'

for some days I got in touch with the IBM federated learning library from github. After finishing the setup, I wanted to run the files for the aggregator and parties in my jupyter notebook and ran into a ModuleNotFoundError as you can see on the picture attached.
What can not be the cause:
a) Jupyter uses different Python as pip does. Both are using 3.8
b) Jupyter tries to load from a wrong directory: As you can see on the code we are loading generate.data from the directory /home/jovyan/FL_MNIST/federated-learning-lib/federated-learning-lib/examples, and the file generate.data is in the directory /home/jovyan/FL_MNIST/federated-learning-lib/federated-learning-lib/examples.
Did anyone ran into this also using the IBM library and could solve it? or do you have a well educated guess what can be the cause?
Best regards,
Solaris

import win32api in python 3.7 resulting in dll import error

I am having the error while running jupyter notebook. Error replication:
python --version
Python 3.7.9
python
import win32api
The error was: ImportError: DLL load failed
After doing a some stackoverflow, I got to know that there are 2 dll files missing namely: pythoncom37.dll and pywintypes37.dll
I also got to know that I can run this post command: pywin32_postinstall.py in the Scripts folder. I ran this script. Restarted my pc. I manually download these two dll and copied it to my system32. After manually downloading, I started to have a different type of error: ImportError: DLL load failed: %1 is not a valid Win32 application
I used anaconda and ran my jupyter notebook which was my main aim but can you please make me aware as what is going wrong?
I've run into this recently, but with a different version of the DLLs. What solved it for me was using a different version of pywin32.
My solution (conda env, python 3.8.5):
pip install pywin32==300
or try 225, 227, 228. The latest pywin32 (301 as of this post) seems to be having dll search issues (I wouldn't be surprised if whatever version you were using is also having dll search issues). 301 was released after your issue started, but you may have a similar problem nonetheless.
There is currently an issue on pywin32 DLL loading failing: https://github.com/mhammond/pywin32/issues/1709
Factors involved (in my experience) include your PATH variable (if you're using conda). I haven't tested it myself, but I'd be curious to see if this issue occurs without conda. This issue stops happening for me if the first dlls found are those for 301. In my case, that means putting them in my C:\Windows\System32 folder (yeah I'm on Windows; joy).
So a possible solution #2 would be to run the pywin32 post install script which should be located under your venv/Scripts/pywin32_postinstall.py
To try that solution, open an ADMIN command prompt (very important that it's admin), navigate to your venv, and run:
ppython.exe Scripts\pywin32_postinstall.py --install
You shouldn't HAVE to do this, but if you just need a one-off solution and it works, great!
pip install --upgrade pywin32 ==225 worked for me. Tried version 300 and was unsuccessful.

Anaconda Prompt(Anaconda3) does not recognize files in a directory

I took to heart the message that support for anaconda2 was dropped. I installed anaconda3 and used 2to3 to convert my *.py codes. Everything seemed to work as expected. I have several 2 line bat codes that cd to a particular directory and then call python to execute a particular *.py code in that directory. By loading Anaconda Prompt(Anaconda3) and invoking the bat file I could run pythons in that directory as expected.
Then, a couple of days ago, I made such a run and got an error message saying the *.py file could not be found. I immediately looked in the directory and the python file was there as expected. I then did a dir command in Anaconda Prompt(Anaconda3) and found that almost no files in the directory were listed. This was happening on my windows 10 laptop.
On my desktop, everything continues to work as expected. Are there any suggestions as to what could cause such a problem and how to fix it.
Thanks,
Mack Elrod
Responding to the request for additional information, I have a bin directory that is in path. In bin\MackData.bat is
c:
cd %USERPROFILE%\Documents\Medev\MackData
copy sugarhist.png sugarhist.old.png
python MackData.py
When I open Anaconda Prompt(Anaconda3) and enter MackData I get
(base) C:\Users\Mack>MackData
(base) C:\Users\Mack>c:
(base) C:\Users\Mack>cd C:\Users\Mack\Documents\Medev\MackData
(base) C:\Users\Mack\Documents\Medev\MackData>copy sugarhist.png sugarhist.old.png
1 file(s) copied.
(base) C:\Users\Mack\Documents\Medev\MackData>python MackData.py
python: can't open file 'MackData.py': [Errno 2] No such file or directory
(base) C:\Users\Mack\Documents\Medev\MackData>
But MackData.py is a python file in the directory MackData.
This code worked on this laptop until a few days ago and continues to work on my desktop computer. I can, of course, publish MackData.py but that seems irrelevant. The point is that Anaconda can't find it.
Thanks,
Mack
I must submit a sincere apology to this community. I have determined my problem and Anaconda is not responsible in any way. I thank all of you for you concerns and comments.
For any who might be interested I will give a brief outline of what happened. First, I installed Anaconda3. Several days later my directory, MackData, was moved to a new location. I conjecture that happened by me inadvertently letting my hand drag on the touch pad. Then, not knowing the location had changed I updated my laptop from my desktop. My update program not finding MackData where expected recreated it and put only the most recently changed files from the desktop into the new MackData. New but in the correct location. Then of course running my script in the Anaconda3 prompt failed. Doing a dir in the Anaconda3 prompt showed only a few files were there. I then went to Windows File Explore and looked at MackData and saw all of the expected files. I used the quick access feature which unknown to me pointed to the old directory in its new location.
That is not intended to be an excuse but only as an explanation. Again, I do apologize to the community.
Mack Elrod
I'm pretty sure newer anaconda launchers users different environment paths, and not even windows ones.
I suggest either checking the environment path within the anaconda launcher and configurations or, a better solution in my opinion, run these scrips using the regular python engine, without using anaconda (simpler, more determinant and works within your standard environment)

Trying to test Python on Win 10, getting Errno 2. Path to python is given to the value of env variable

I've installed Python 3.8 on Win 10 machine. Path to Python is C:\Users\userid\AppData\Local\Programs\Python\Python38\
Path environment variable values are: C:\Users\userid\AppData\Local\Programs\Python\Python38\Scripts\;C:\Users\userid\AppData\Local\Programs\Python\Python38\python.exe
In order to test python, I created a simple script called "script.py" in directory C:\python_scripts.
Then I tried to run "script.py" from the directory where it is located, but got error:
C:\python_scripts> python script.py
C:\Users\userid\AppData\Local\Programs\Python\Python38\python.exe: can't open file 'script.py': [Errno 2] No such file or directory
What might be the cause of getting this error? i tried to run the script with both cmd and powershell, with the usual user rights and with elevated admin rights, still getting Errno 2.
No other versions of Python have been previously installed on this machine (which is a corporate one, if that might be significant)
Thank you
Thank you #OferSadan for your suggestion to use dir command, it helped me to solve the problem. The "script.py" had an additional .txt extension added to it for some reason, but the Windows explorer only showed .py extension by default. Now I deleted the trailing .txt suffix and the script runs

Unable to change Python path in CentOS

I have Python installed in the server and its default path is:
/usr/lib/python2.7
But it somehow got changed and when I am running my programs this is what i am getting.
File "/home/satbeersl/miniconda2/lib/python2.7/json/decoder.py", line 382, in raw_decode
raise ValueError("No JSON object could be decoded")
It got changed to :"/home/satbeersl/miniconda2/lib/python2.7.
How can i change it back. I tried:
export PATH=$PATH:/usr/lib/python2.7
Its still not changing. New to linux, can't figure out what to do. None of my programs seem to be working suddenly. Help.
Please check if you are using virtual environments for Python on your system - they alter the real path to Python and pip to a project location.
Try deactivate command if you are using virtualenv to stop the virtual environment.
If you still haven't tried it in terminal ask which python and which python3 to check the paths and compare them.
Hope this helps.

Resources