Changing which Python Coderunner 3.0 uses to Anaconda's python - python-3.x

I use the Coderunner 3.0 application on my mac for all of my python coding. I don't know how to import any libraries to it and when writing sys.executable in Coderunner it prints /usr/bin/python3. I want to use the version of Python I have from anaconda which is in /Users/myuser/anaconda3/bin but when putting that in the run command nothing changed. Does anyone know how to do this?
python3 $filename anaconda/bin is what I tried using
and when I just enter
Users/myuser/anaconda3/bin in the run command it says Users/myuser/anaconda3/bin is a directory

As described on the CodeRunner support page, the syntax for the run command is essentially:
/path/to/interpreter $filename
So if Anaconda is located at /Users/myuser/anaconda3/bin, the correct command would be:
/Users/myuser/anaconda3/bin/python3 $filename

Related

How to execute python program made on IDE from command prompt

I usually use pycharm for coding.
My question is how I can replace execution by IDE to command prompt execution. IDE makes it easy to set all python environments.
Windows 10 / Anaconda 3 / Python 3.7
My goal is to execute python program by windows scheduler.
Please let me know how to execute it.
Thanks.
Just open a command prompt, and then type:
python path_to_your_code/your_code.py
If this gives you errors that numpy, pandas etc are not installed then it means that the interpreter being used by your IDE (where you did not get such errors) is not the same one pointed at by python in command line.
If you're using a virtual environment or a python installation other than the default one you can just replace the python with a full path to the python binary in the environment you are using. So assuming your IDE is using the Anaconda environment, try this from command line:
c:\Anaconda3\python.exe path_to_your_code\your_code.py
Adding c:\Anaconda3 to PATH will not help if you already have another version of Python installed elsewhere, it will just mean that you now have two python.exe files in your path and python will still point at the same one.
However if where python already returns the path above, it means that your IDE is not using this interpreter and you'll need to find which one it is using. You can check this by looking in the Project Interpreter options or by running this script
import sys
print(sys.executable)

Mismatch between python3 version from command line and version in /usr/local/lib

When I start python3 in terminal, it runs python 3.6.5.
However, when I look in /usr/local/lib, I see python 3.7 and all it's site-packages.
Why is there a discrepancy? Shouldn't the version always match when I update? Does this matter?
The command which python will tell you the path to the executable that is being chosen. Use echo $PATH to see which directories are checked for files to run and in which order - this should help you to understand which file is being chosen and why.

How can I get pylint to use python 3 in VS code?

I want pylint to use python3 for linting in Visual Studio code on Mac (which has both python 2.7 standard and python 3.6).
I've tried changing the path to the python interpreter as per How can I debug Python3 code in Visual Studio Code, to no avail. I keep getting python2 errors instead of python3 errors.
See example code for the problem.
Is there a way I can get pylint to recognize python3 errors?
Pick a xx.py in Visual Studio Coce(VSC)
In Status Bar Tap Python 2.7.10 like the [img1]
Choose python 3.x like [img2]
Command+Q quit VSC, then open VSC again
I finally got it working by installing python3 pylint from the console.
sudo python3 -m pip install -U pylint
The simple solution is to just change the first line of the file /home/user_name/.local/bin/pylint from #!/usr/bin/python2 to #!/usr/bin/python3
If you want more, you can rename this file to pylint2 and have a copy pylint3 where you change the first line to #!/usr/bin/python3.
Now to use pylint3 from command line you just need to type pylint3 instead of pylint.. also change the directory of pylinter in vscode to /home/user_name/.local/bin/pylint3
explanation
Ok this might be very late and the answer might not be the optimum, but I had the same issue.
By default the path to pylint is /home/user_name/.local/bin/pylint that is a simple python script working as the entry point to pylint.. even after installing pylint using pip3 this file is not changed and keeps directing to use python2 and therefore the packages installed by pip2 for python2.
So either have separate entry points for each pylint version, or modify this one manually to use the pylint package installed for python3.

'python3' is not recognized as an internal or external command, operable program or batch file

I am using Python 3.5.2 version on Windows 7 and tried using python3 app.py. I am getting this error message:
'python3' is not recognized as an internal or external command,
operable program or batch file.
Is there any specific cause about why the python3 command is not working?
I also verified that the PATH is added to environment variables.
There is no python3.exe file, that is why it fails.
Try:
py
instead.
py is just a launcher for python.exe. If you have more than one python versions installed on your machine (2.x, 3.x) you can specify what version of python to launch by
py -2 or
py -3
You can also try this:
Go to the path where Python is installed in your system. For me it was something like C:\Users\\Local Settings\Application Data\Programs\Python\Python37
In this folder, you'll find a python executable. Just create a duplicate and rename it to python3. Works every time.
Python3.exe is not defined in windows
Specify the path for required version of python when you need to used it by creating virtual environment for your project
Python 3
virtualenv --python=C:\PATH_TO_PYTHON\python.exe environment
Python2
virtualenv --python=C:\PATH_TO_PYTHON\python.exe environment
then activate the environment using
.\environment\Scripts\activate.ps1
Yes, I think for Windows users you need to change all the python3 calls to python to solve your original error. This change will run the Python version set in your current environment. If you need to keep this call as it is (aka python3) because you are working in cross-platform or for any other reason, then a work around is to create a soft link. To create it, go to the folder that contains the Python executable and create the link. For example, this worked in my case in Windows 10 using mklink:
cd C:\Python3
mklink python3.exe python.exe
Use a (soft) symbolic link in Linux:
cd /usr/bin/python3
ln -s python.exe python3.exe
In my case I have a git hook on commit, specified by admin. So it was not very convenient for me to change the script (with python3 calls).
And the simplest workaround was just to copy python.exe to python3.exe.
Now I could launch both python and python3.
If python2 is not installed on your computer, you can try with just python instead of python3
For Python 27
virtualenv -p C:\Python27\python.exe django_concurrent_env
For Pyton36
virtualenv -p C:\Python36\python.exe django_concurrent_env
Enter the command to start up the server in that directory:
py -3.7 -m http.server
I had a related issue after installing windows 11, where python3 in cmd would open the windows store. I was able to sort it out between this post and this other one. In short, I reinstalled python and made sure to add it to PATH. Then, in settings, Apps > Apps & Features > App Execution aliases. Here, all I had to do was make sure that every single python .exe (including idle and pip) were turned off EXCEPT FOR the python3.exe alias. Now it works like a charm.
FWIW:
The root of this issue is not with you or with python. Apparently, Microsoft wanted to make installing python easier for young kiddos getting interested in coding, so they automatically add an executable to PATH. For those of us that already have this executable, it can cause these issues.
Found out instead press the play button the top right and it should work in visual studios:
Do not disable according to first answer
Saying python3 in the command will not work by default.
After figuring out the problem with the modules (Solution): https://youtu.be/paRXeLurjE4
Summary:
To import python modules in case of problem to import modules:
Hover over python in search:
Click open in folder
Hover over and right click
click properties
copy everything in path before \python.exe
close those windows
For cmd (administrator):
cd --path that was copied--
then python -m pip install --upgrade pip
cd Scripts
pip install "Name of Package" such as pip install --module (package) --
Im on win10 and have 3.7, 3.8 and 3.10 installed.
For me "python" launches version 3.10 and does not accept commands (like -3.7), "py" launches newest version but does accept commands, and "python3" does nothing.
Uninstalled 3.10 and "python" now does nothing, and "py" launches 3.8.
I am unable to add a comment, but the mlink option presented in this answer above https://stackoverflow.com/a/55229666/8441472 by #Stanislav preserves cross-platform shebangs at the top of scripts (#!/usr/bin/env python3) and launches the right python.
(Even if you install python from python.org, Windows will direct you to the app marketplace nowadays if you type python3 on the command line. If you type python on the same cli it will launch the python.org version repl. It leads to scripts that generate no output, but more likely silently failed completely. I don't know ho common this is but have experienced it on a couple of different devices)
If you have this at the top of your script to ensure you launch python3 and don't feel like editing everything you own, it is not a bad approach at all... lol.

How to set python 3.4 as default over 2.7 in dual installation

I recently downloaded version 3.4 and installed it but when I go to the command line and type python -V I get Python 2.7.6 How do I set python 3.4 as my default version.
The first step to do is to find where is your python.
You can do it with which or where command (which for unix where for windows). Once you have this information you will know what is actually executed as "python" command. Then you need to change it for windows (i believe) you need to change the PATH variable in such a way that your python 3.4 will be found earlier then 2.6
For the unix you need to either do the same or link it in your package manager.
You need to use python3 to use python 3.4. For example, to know version of Python use:
python3 -V
This will use python 3.4 to interpret your program or you can use the shebang to make it executable. The first line of your program should be:
#!/usr/bin/env python3
If you want python3 to be used when you type python on the terminal, you can use an alias. To add a new alias, open your ~/.bash_aliases file using gedit ~/.bash_aliases and type the following:
alias python=python3
and then save and exit and type
source ~/.bash_aliases
and then you can type
python -V
to use python3 as your default python interpreter.

Resources