Why did the python version not switch after conda switched the environment? - python

python3.7.12 should be the python version of the hsm environment
(hsm) leelee#ubuntu-PowerEdge-T440:~/tools/hsm-master/predict$ which python
/home/leelee/miniconda3/envs/hsm/bin/python
(hsm) leelee#ubuntu-PowerEdge-T440:~/tools/hsm-master/predict$ /home/leelee/miniconda3/envs/hsm/bin/python
Python 3.7.12 | packaged by conda-forge | (default, Oct 26 2021, 06:08:21)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()
But if I type python directly, it will return a 3.9.5 python version
(hsm) leelee#ubuntu-PowerEdge-T440:~/tools/hsm-master/predict$ python
Python 3.9.5 (default, Jun 4 2021, 12:28:51)
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()
I guess when I type python, I entered /home/leelee/miniconda3/bin/python
(hsm) leelee#ubuntu-PowerEdge-T440:~/tools/hsm-master/predict$ which -a python
/home/leelee/miniconda3/envs/hsm/bin/python
/home/leelee/miniconda3/bin/python
(hsm) leelee#ubuntu-PowerEdge-T440:~/tools/hsm-master/predict$ /home/leelee/miniconda3/bin/python
Python 3.9.5 (default, Jun 4 2021, 12:28:51)
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()
Why does this happen and how can I solve it?

Looks like you added Python to the system PATH, which is not recommended when using conda. Simply check your PATH after conda activation and have a look at the sequence of the Python folders.

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.

python virtualenv different behavior from activate and bin/python

I created virtualenv for few months. And I encountered a problem.
When I activate virtual environment I have access to lib like django :
source virtualenv/jsms/bin/activate
(jsms)local% python
Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 23 2015, 02:52:03)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> exit()
(jsms)local% deactivate
But when I use python from the bin folder I can't access to django :
local% virtualenv/jsms/bin/python
Python 2.7.10 (default, Oct 23 2015, 19:19:21)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named django
More strange, when I use python3.4 from the bin folder, I am using python 2.7 :
local% virtualenv/jsms/bin/python3.4
Python 2.7.10 (default, Oct 23 2015, 19:19:21)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Do you know a way to access lib directly from python in the bin folder ?
activate is just a bash script, so you can always take a look at the activate file and see what it is doing, but I think what you’re looking for is the env variable PYTHONHOME. I would try:
export OLD_PYTHON_HOME="$PYTHONHOME"
unset PYTHONHOME
virtualenv/jsms/bin/python3.4 --version
For windows, you would use the following code from the activate.bat template:
if defined PYTHONHOME (
set _OLD_VIRTUAL_PYTHONHOME=%PYTHONHOME%
set PYTHONHOME=
)

Caffe import working with python2 but not python2.7 / ipython notebook, despite both being 2.7.10?

I've successfully compiled the caffe library and the python module.
I can do this:
Jamess-Air:~ james$ python2 -V
Python 2.7.10
Jamess-Air:~ james$ python2
Python 2.7.10 (default, Jul 13 2015, 12:05:58)
[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import caffe
>>>
But, bizarrely, this fails:
Jamess-Air:~ james$ python2.7 -V
Python 2.7.10
Jamess-Air:~ james$ python2.7
Python 2.7.10 (default, Jun 19 2015, 15:39:31)
[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import caffe
Segmentation fault: 11
Jamess-Air:~ james$
I cannot understand this at all! Whenever I try to run using iPython notebook I get the same crash.
Any ideas as to what may be causing this, and how I might fix it, or at least get iPython Notebook to use the different python version so I can run this thing?
Thanks!

libsvm on linux - how to add path

I downloaded the tar file for libsvm, navigated to the python directory and ran the make command. This words and when I run python inside that same directory,
import svm
works just fine. But not in any other directory. What can I do to make this library accessible from any where? I know it has some thing to do with copying the path some where, but not sure since I'm a newbie at linux.
what linux distro are you on? on my Ubunto I just:
$ sudo apt-get install python-libsvm
...
$ python
Python 2.7.3 (default, Sep 26 2013, 20:03:06)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import svm
>>>
$ cd /tmp
$ python
Python 2.7.3 (default, Sep 26 2013, 20:03:06)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import svm
>>>

Python 2.7.3 not working in Mavericks Terminal :(

so i upgraded to Mavericks hoping that my scripts would be fine . . . luckily when I run my scripts in Coderunner they work . i do simple test scripts in the terminal because its easy and i like the way it looks. i'm not sure why the frameworks work in coderunner but not the terminal.
does anyone have any idea how to fix this ?
i tried updating the software and got the same error
Last login: Wed Oct 30 11:08:51 on ttys000
opus-magnum:~ Opus_Magnum$ python
Python 2.7.5 (v2.7.5:ab05e7dd2788, May 13 2013, 13:18:45)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> s = 'hello'
>>> print s
Segmentation fault: 11
opus-magnum:~ Opus_Magnum$
`
You are not running the correct version of python that was released with OS X Mavericks.
[1:17pm][wlynch#watermelon ~] /usr/bin/python2.7
Python 2.7.5 (default, Aug 25 2013, 00:04:04)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>

Categories