Python3 installed, but why can't I run python file in terminal - python

I am trying to run a python3 file out of the directory the file is located in on macOS catalina.
so I type the following:
python3 <file_name>
and nothing happens in my terminal, it just starts a new line in the same directory, but no file runs.
Up until now I have only ever used a jupyter notebook to run python, but now I am trying to run VS code and run the file inside of the terminal.
Anyone know how to fix?

I just wanted to say I fixed the problem trying a number of different solutions:
I downloaded the most recent version of python, ran certificates and update commands.
I selected the new python interpreter from VS code using shift+cmd+P and select interpreter option.
I ran the file in python launcher and then again in terminal and it works fine now. Thanks for participating in helping me solve this issue.
Alternatively if anyone else has similar problems, try the steps I mentioned, or maybe try setting up a pyenv to run python files in a virtual python environment.

Related

Running python in vscode terminal

I want to run python on vscode terminal but when i try to do so i get the following:
I use the code runner extension and i am enabling 'run code in terminal'option.
It used to work for me, but i have tried recently to run python on windows terminal by copying the entire thing vscode generates in it's terminal when building the executable(the path and everything) and pasting it to windows terminal, didn't work.
This is what i pasted: C:\Users\Yan\AppData\Local\tmc\vscode\mooc-programming-22\part05-27_letter_square> python -u "c:\Users\Yan\AppData\Local\tmc\vscode\mooc-programming-22\part05-27_letter_square\src\letter_square.py"
Please tell how to fix this and if what i did is the cause, then tell me also how to run python on windows terminal without causing this problem.
The command pasted to the windows terminal has somehow created a file named "python" (with no extension) in the "System32" folder.
Delete the file and the problem is solved.

System crashes each time i run python command in Terminal, how to get rid of /opt/miniconda3/bin/python?

please I need your help here!
My system crashes each time i run a python command in terminal. When i run something like python app.py, my Mac will crash and bounce, and reset.
In Terminal,
When i run python -V, it returns Python 3.7.6,
When i run python3 -V, it returns Python 3.8.5
When i run which python, it returns /opt/miniconda3/bin/python.
A moment ago, i was trying to build a standalone app, and turned on virtualenv. However no matter how hard i tried, i failed. Then i deleted the virtualenv folder in the app folder.
Perhaps during the development processes, in Visual Studio Code, i accidentally "linked" the virtualenv with the python interpreter 3.7 (/opt/miniconda3/bin/python), which was set as the default python system long ago (i can't even recall when and how). After the virtualenv folder deletion, i remember the interpreter had the word "cached" in the front of the python version. Somehow i turned on and off this and that, and restarted the app, i have get rid of the word "cached". But the system still crashes .
My Mac crashes now every time i run a python command in Terminal. Please help!
i even have tried update conda update conda, it says no such directory,
ofcoruse i then tried update miniconda, same answer.
You should remove it from your path.
To do so, check for the miniconda3 entry in the file named ~/.bashrc, ~/.bash_profile, and /etc/profile file and comment out the line:
export PATH=/opt/miniconda3/bin:$PATH
by preceding it with the # character.

running python files in powershell

For a project at school I need to run a python file using powershell. I tried installing the interpreter and using the command python pythonTest.py but nothing happened.
Do i need to import something in powershell?
You have to check the box add python to path when you install python. So first uninstall then reinstall making sure you ticked the checkbox and proceed then you can run python files in powershell.
FIXED
I was running it in admin mode and apparently it doesn't work when you're in adminmode

Python ran from command line runs version 3.6 while in my files it runs version 3.4

So I have 2 versions of python on my machine, one located at: # python 3.4
c:/Python34
other located at: # python 3.6
c:\users\USERNAME\appdata\local\programs\python\python36-32
The python 3.6 version has all the libraries I would like to use, however when I try to run my python scripts I get errors saying the module doesn't exist.
Now if i run python though the command line like this it works fine.
So I would like to force my scripts to run though the version where I have all the libraries downloaded.
In my path I have.
C:\Users\USERNAME\AppData\Local\Programs\Python\Python36-32\Scripts;
C:\Users\USERNAME\AppData\Local\Programs\Python\Python36-32\;
C:\Users\USERNAME\AppData\Local\Programs\Python\Launcher;
So when I run my program in the command line I would like it to run using the correct version of python I don't know why its using the other one and it's driving me nutz!
I've uninstalled and reinstalled pandas and numpy with pip install and pip uninstall
I've switched the environment variables to point to Python34 in my command line and attempted to install pandas on that but it was too painful.
I'm writing the code in Sublime Text and running it though the command line just by typing
examplecode.py
When i run
assoc.py
and
ftype Python.file
i get theses messages
This was fixed simply by creating a virtual environment with the libraries i needed.
Thanks to ascripter for the advice.
I would have rather just deleted the python 3.4 however this isnt my machine so i don't want to make any waves. good suggestion abarnert!

Issue with Python on Windows 10

Specifically on my shiny new Surface Pro 2017 (i5, 256GB, 8GB RAM). So I'm trying to set up my dev environment and I'm running into a bit of a snag.
It shows up as installed through Powershell -and I'm able to run Python fine through it- but when I try the same on my Bash and Hyper terminals, no luck. I'm realizing now that Bash is not pictured in the screenshot, but it says the same thing when I try to run python commands. Did my due diligence in searching through the Surface subreddit, Google, and of course, Stack.
Anyone know what could be the issue?
Screenshot
In my opinion the best solution is to install python inside your bash environment, too. What is the main reason you even want to call the Windows version of python from the bash? If installing python inside the Ubuntu subsystem/the bash again, then you might try to find out the path to the python.exe inside your Windows installation and try to add these path to your bash's path, too.
Do yourself a huge favor and install Anaconda, and use command line prompt from now on and don't even Touch Powershell or bash. It's windows not linux. The reason I say anaconda is because it gives you a huge array of libraries and also you can create a virtual environment meaning if Python gets screwed on or corrupted at least your file paths will be okay.

Categories