activating anaconda python even if it's not on conda environment - python

literally.
in cmd, I want to execute window's python, not conda's
but it always executes conda's
Like this:
C:\Users\RHS>python
Python 3.9.12 (main, Apr 4 2022, 05:22:27) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Warning:
This Python interpreter is in a conda environment, but the environment has
not been activated. Libraries may fail to load. To activate this environment
please see https://conda.io/activation
Type "help", "copyright", "credits" or "license" for more information.
What I want to execute is window's python.
Like this:
C:\Users\RHS\AppData\Local\Programs\Python\Python39>python
Python 3.9.13 (tags/v3.9.13:6de2ca5, May 17 2022, 16:36:42) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
I added PATH of python 3.9 and tried changing position of both.
but always same result

Related

Conda environment's python segmentation fault

I I'm trying to use python with conda environment.
I create an environment using
conda create -n new_env3 python=3.9
Then when I start python terminal (just running 'python') I get:
Python 3.9.12 (main, Apr 5 2022, 06:56:58)
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
Segmentation fault
I tried multiple python versions and sub-versions, but all resulted in the same error
i met the same problem, and conda clean -a didn't solve the problem
$ python
Python 3.10.6 (main, Oct 24 2022, 16:07:47) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
Segmentation fault
Try running conda clean -a.
This will remove all unused packages.

What's the behind magic of python os.path.realpath?

Recently, I tried to install pypoetry on my windows. The python I used was installed from MS store. And I found something strange.
C:\Users\Liu.D.H>where python
C:\Users\Liu.D.H\AppData\Local\Microsoft\WindowsApps\python.exe
C:\Users\Liu.D.H\anaconda3\python.exe
C:\Users\Liu.D.H>C:\Users\Liu.D.H\anaconda3\python.exe
Python 3.8.8 (default, Apr 13 2021, 15:08:03) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Warning:
This Python interpreter is in a conda environment, but the environment has
not been activated. Libraries may fail to load. To activate this environment
please see https://conda.io/activation
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.path.realpath("C:/Users/Liu.D.H/AppData/Roaming/pypoetry")
'C:\\Users\\Liu.D.H\\AppData\\Roaming\\pypoetry'
>>> exit()
C:\Users\Liu.D.H>python
Python 3.10.1 (tags/v3.10.1:2cd268a, Dec 6 2021, 19:10:37) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.path.realpath("C:/Users/Liu.D.H/AppData/Roaming/pypoetry")
'C:\\Users\\Liu.D.H\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\Roaming\\pypoetry'
>>> exit()
C:\Users\Liu.D.H>
I also tried the realpath of node.
C:\Users\Liu.D.H>node
Welcome to Node.js v14.18.1.
Type ".help" for more information.
> fs.realpathSync("C:/Users/Liu.D.H/AppData/Roaming/pypoetry")
Uncaught:
Error: ENOENT: no such file or directory, lstat 'C:\Users\Liu.D.H\AppData\Roaming\pypoetry'
at Object.realpathSync (fs.js:1800:7) {
errno: -4058,
syscall: 'lstat',
code: 'ENOENT',
path: 'C:\\Users\\Liu.D.H\\AppData\\Roaming\\pypoetry'
}
>
So, the %APPDATA%/sub_path location in windows is process-dependent?

Different python versions in the same environment of Anaconda

this is what the cmd shows:
C:\Users\74713\Documents>activate root
(root) C:\Users\74713\Documents>python
Python 3.6.2 |Anaconda custom (64-bit)| (default, Jul 20 2017, 12:30:02) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
this is what my IDE shows:
Python 3.6.3 |Anaconda custom (64-bit)| (default, Oct 15 2017, 03:27:45) [MSC v.1900 64 bit (AMD64)]
Type "copyright", "credits" or "license" for more information.
IPython 6.1.0 -- An enhanced Interactive Python.
the first one's version is 3.6.2 while the second one is 3.6.3
and because of that, I meet trouble in import torchtext, which works well in the cmd(3.6.2) while fails in my IDE(3.6.3)

Running specific python interpreters form command line

When I open CMD (on windows 10) and enter python it initializes python 3.6.0
C:\>python
Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
Now I recently also installed 2.7.6 the interpreter. How can I call both version of Python from CMD?
desired outcome
C:\>python
Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> ^Z
C:\>python2.6
Python 2.7.6 (default, Nov 10 2013, 19:24:24) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
You can use Python launcher for Windows:
Python 2.7 interptreter:
C:\> py -2.7
Python 3.6 interpreter:
C:\> py -3.6
You also can run a script with a specific interpreter:
C:\> py -2.7 myScript.py
If its windows machine, to open a specific version of python you can use py from the command line.
example:
py2.7 #for version 2.7
and
py3.6 #for version 3.6
if its a Linux machine you can use the following commands in the command line python
python2.7 #opens version 2.7
and
python3.6 #opens version 3.6

How do I setup virtualenvwrapper for Windows PowerShell?

I have this installed
on Windows 7
Python 2.7.6 (my default, with virtualenv installed)
Python 2.4.4
Python 2.5.4
Python 2.6.6
Python 3.3.3
virtualenv 1.10.1
virtualenvwrapper_powershell-12.7.8-py2.7
I want to test code on all of those python installations.
(Related question about missing support for Python 2.4./2.5:
How do I setup virtualenv environments for Python 2.4 and 2.5 versions on Windows? )
This is what I tried so far:
Trying virtualenv directly:
Python 2.6 works as expected:
C:\Users\martin\.virtualenvs>virtualenv -p c:\apps\Python26\python.exe env26
Running virtualenv with interpreter c:\apps\Python26\python.exe
New python executable in env26\Scripts\python.exe
Installing Setuptools..............done.
Installing Pip.............done.
C:\Users\martin\.virtualenvs>env26\Scripts\activate
(env26) C:\Users\martin\.virtualenvs>python
Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
Python 2.7 and 3.3 also work as expected.
Trying virtualenvwrapper:
Python 2.6, 2.7, and 3.3 work as expected:
C:\Users\martin\.virtualenvs>mkvirtualenv -p c:\apps\Python26\python.exe env26_w
Running virtualenv with interpreter c:\apps\Python26\python.exe
New python executable in env26_w\Scripts\python.exe
Installing Setuptools.........done.
Installing Pip................done.
(env26_w) C:\Users\martin\.virtualenvs>python
Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
Trying virtualenvwrapper on Powershell:
Creating and activating Python 2.6 does not give an error, but starts Python27
when activated:
PS C:\Users\martin> mkvirtualenv -p C:\apps\Python26\python.exe env_26_ps
New python executable in env_26_ps\Scripts\python.exe
Installing Setuptools........done.
Installing Pip.......................done.
Added activation script por Powershell to C:\Users\martin\.virtualenvs/env_26_ps\Scripts.
(env_26_ps)PS C:\Users\martin> python
Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
The env_26_ps\Scripts folder contains files like pip-2.7.exe and python.exe (2.7).
Similar behavior for Python 3.3

Categories