Python Forum
Instigating python script from via
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Instigating python script from via
#6
(Sep-03-2022, 08:28 AM)reddwarfcrew Wrote: So can I use via to execute the py script via the conda prompt (ie with base activated)?
Yes when base is active it will use the Anaconda python version no matter what folder you are in.
Can give some tips as i have lot installed and Python versions never interfere if understand how this works.
C:\code
λ python -V
Python 3.10.5

# What python interpreter is used now 
C:\code
λ python -c "import sys; print(sys.executable)"
C:\python310\python.exe

# Test pip(used to install stuff to Python)
C:\code
λ pip -V
pip 22.2.2 from C:\python310\lib\site-packages\pip (python 3.10)
So over is a Python version from python.org
Now will use a Miniconda(same as Anaconda without all 720 packages pre-installed) and activate a environment my own,but works the same as base.
# Activate my environment 
C:\code
λ G:\miniconda3\Scripts\activate.bat tom_env

(tom_env) C:\code
λ python -V
Python 3.10.1

# Point to miniconda 
(tom_env) C:\code
λ python -c "import sys; print(sys.executable)"
G:\miniconda3\envs\tom_env\python.exe

# Point to miniconda 
(tom_env) C:\code
λ pip -V
pip 21.3.1 from G:\miniconda3\envs\tom_env\lib\site-packages\pip (python 3.10)

# Anaconda own installer conda
(tom_env) C:\code
λ conda -V
conda 4.11.0
See that now use a other Python version from Miniconda.
Lest say a have hello.py in folder G:\div_code,can now navigate and run the .py file,as long as (tom_env) or eg (base) is activate it will always use the Miniconda Python version.
(tom_env) C:\code
λ G:

(tom_env) G:\
λ cd div_code

# Run code
(tom_env) G:\div_code
λ python hello.py
hello world

# What python interpreter it used to run code over
(tom_env) G:\div_code
λ python -c "import sys; print(sys.executable)"
G:\miniconda3\envs\tom_env\python.exe
Deactivate it will my other Python version .
(tom_env) G:\div_code
λ conda deactivate

G:\div_code
λ python hello.py
hello world

G:\div_code
λ python -c "import sys; print(sys.executable)"
C:\python310\python.exe
Reply


Messages In This Thread
RE: Instigating python script from via - by snippsat - Sep-03-2022, 09:29 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Is there a *.bat DOS batch script to *.py Python Script converter? pstein 3 3,527 Jun-29-2023, 11:57 AM
Last Post: gologica
  How to kill a bash script running as root from a python script? jc_lafleur 4 6,078 Jun-26-2020, 10:50 PM
Last Post: jc_lafleur
  crontab on RHEL7 not calling python script wrapped in shell script benthomson 1 2,387 May-28-2020, 05:27 PM
Last Post: micseydel
  Package python script which has different libraries as a single executable or script tej7gandhi 1 2,687 May-11-2019, 08:12 PM
Last Post: keames
  How to run python script which has dependent python script in another folder? PrateekG 1 3,219 May-23-2018, 04:50 PM
Last Post: snippsat
  How to call one python script and use its output in another python script lravikumarvsp 3 32,556 May-16-2018, 02:08 AM
Last Post: lravikumarvsp
  Check Python version from inside script? Run Pythons script in v2 compatibility mode? pstein 2 9,917 Jul-07-2017, 08:59 AM
Last Post: snippsat
  Cant pass corect variables to python script in bash script neradp 3 6,294 Nov-05-2016, 01:26 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020