Conda environment wrong pyyaml version - python-3.x

conda list pyyaml
# packages in environment at c:\Anaconda3:
#
# Name Version Build Channel
pyyaml 3.13 py36hfa6e2cd_1001 conda-forge
conda env list
# conda environments:
#
C:\Anaconda3
base c:\Anaconda3
yaml * c:\Anaconda3\envs\yaml
Switching to yaml environment
activiate yaml
conda list pyyaml
# packages in environment at c:\Anaconda3\envs\yaml:
#
# Name Version Build Channel
pyyaml 5.2 py36he774522_0
Starting Python within environment yaml with python
Python 3.6.9 |Anaconda, Inc.| (default, Jul 30 2019, 14:00:49) [MSC v.1915 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import yaml
>>> yaml.__version__
'3.13'
Why is 3.13 and not 5.2 returned?
Update 2019-12-17, 14:32
(base) D:\a\buch>
(base) D:\a\buch>conda activate yaml
(yaml) D:\a\buch>
(yaml) D:\a\buch>python
Python 3.6.9 |Anaconda, Inc.| (default, Jul 30 2019, 14:00:49) [MSC v.1915 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import yaml
>>> yaml.__version__
'3.13'
>>>
(yaml) D:\a\buch>c:\Anaconda3\envs\yaml\python.exe
Python 3.6.9 |Anaconda, Inc.| (default, Jul 30 2019, 14:00:49) [MSC v.1915 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import yaml
>>> yaml.__version__
'3.13'
>>>

That is because in anaconda by default you will be in the base environment where the version of pyyaml is 3.13(in your case).
If you activate the environment yaml and check the version of pyyaml, you will find the 5.2 version of pyyaml
The problem in your case is that you are in the same base environment. Kindly use the following command to switch to the other environment.
conda activate yaml
You forgot to use the conda command before activate yaml hence you are in the same base environment.
Kindly follow this link also.
Hope this will help you.

Related

Python2 doesn't work when both python3.8 and python2.7 are installed on Anaconda3

I installed Anaconda and used Python3.8.8 as the base environment, now I create a new environment named py27 to install python2.7, but it doesn't work.
Here are the details
(base) C:\Windows\System32>conda env list
# conda environments:
#
base * C:\ProgramData\Anaconda3
pix2vox C:\Users\10531\.conda\envs\pix2vox
py27 C:\Users\10531\.conda\envs\py27
(base) C:\Windows\System32>python
Python 3.8.8 (default, Apr 13 2021, 15:08:03) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
(base) C:\Windows\System32>conda activate py27
(py27) C:\Windows\System32>python
File "C:\ProgramData\Anaconda3\lib\site.py", line 178
file=sys.stderr)
^
SyntaxError: invalid syntax
(py27) C:\Windows\System32>
My environment variable PATH contains
C:\ProgramData\Anaconda3;
C:\ProgramData\Anaconda3\Scripts;
C:\ProgramData\Anaconda3\Library\mingw-w64\bin;
C:\ProgramData\Anaconda3\Library\usr\bin;
C:\ProgramData\Anaconda3\Library\bin;
I want to use both python3.8 and python2.7 simultaneously, please help me, thanks!
I fixed it.
Delete the PYTHONHOME environment variable, I set it as C:\ProgramData\Anaconda3; before.
Delete
C:\ProgramData\Anaconda3\Library\mingw-w64\bin;
C:\ProgramData\Anaconda3\Library\usr\bin;
C:\ProgramData\Anaconda3\Library\bin;
in Path, I didn't know if it works, but I did it.
Add new entries
C:\Users\10531\.conda\envs\py27;
C:\Users\10531\.conda\envs\py27\Scripts;
in PATH.
Rerun the terminal.

Unable to import Pandas in IPython 6.5.0 console (Spyder)

After installing pandas am able to import in cmd as below :
C:\Users\me\Desktop\Django_Project>python
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit
(AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas
>>>
But when am importing pandas in Spyder in IPython 6.5.0 console I get below error:
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v.1914 32 bit (Intel)]
Type "copyright", "credits" or "license" for more information.
IPython 6.5.0 -- An enhanced Interactive Python.
c:\program files (x86)\python37-32\lib\site-packages\ipykernel\parentpoller.py:116: UserWarning: Parent poll failed. If the frontend dies,
the kernel may be left running. Please let us know
about your system (bitness, Python, etc.) at
ipython-dev#scipy.org
ipython-dev#scipy.org""")
In [1] : import pandas
Traceback (most recent call last):
File "<ipython-input-1-38d4b0363d82>", line 1, in <module>
import pandas
ModuleNotFoundError: No module named 'pandas'
In [2] :
Note: I have installed python in "C:\Users\me\AppData\Local\Programs\Python\Python37\" path and environment variables is set as "C:\Users\me\AppData\Local\Programs\Python\Python37;"
And I installed pandas using PIP
Please suggest the solution to resolve this issue.I have tried reinstalling the pandas package almost 6-7 times.
I think you should open anaconda command prompt by searching it in windows search bar . Now write there "conda install -c anaconda pandas" and try again to run the program

How to install omniORB for python3?

I could get omniORB running in python2.7 by just executing the configure script.
ubuntu#ubuntu:/usr/local/bin$ export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
ubuntu#ubuntu:/usr/local/bin$ python2
Python 2.7.12 (default, Dec 4 2017, 14:50:18)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import omniORB
>>>
However, running
../configure PYTHON=/usr/bin/python3
didn't do the trick for python3:
ubuntu#ubuntu:/usr/local/bin$ python3
Python 3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import omniORB
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'omniORB'
>>>
When running ../configure without any options, the script outputs:
...
checking for python... /usr/bin/python
checking for python version... 2.7
checking for python platform... linux2
...
When running ../configure PYTHON=/usr/bin/python3 , the script outputs:
...
checking for python version... 3.5
checking for python platform... linux
checking for python script directory... ${prefix}/lib/python3.5/site-packages
...
I'm using ubuntu 16.04 and the latest omniorb 4.2.2.
I also faced same problem too (I'm using ubuntu 18.04 and omniORB 4.2.3).
In my case, omniORBpy was installed in /usr/local/lib/python3.6/site-packages, but the directory is not in python's sys.path.
You should check sys.path and where omniORBpy is installed.

Pycharm: why I can't import cabocha library

My os is Mac OS, and I have install successfully conda, and cabocha.
and I can import cabocha.analyze (which is a Yet Another Japanese Dependency Structure Analyzer - GitHub Pages ) successfully in terminal.
(wmm_env) A1706-084:wmm_env k.den$ python
Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 12:04:33)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from cabocha.analyzer import CaboChaAnalyzer
>>>
But in the pycharm, there is error:
from cabocha.analyzer import CaboChaAnalyzer
ModuleNotFoundError: No module named 'cabocha'

Use graphviz with python3

I try to draw a decision tree using the graphviz module, and it works fine with python2. Is there a way to use this module with python3?
Is there any other module that supports drawing decision trees in python3?
Did you install graphviz for python3? It works fine for me:
andi#sunnyside:~$ python3
Python 3.5.3 (default, Jan 19 2017, 14:11:04)
[GCC 6.3.0 20170118] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import graphviz
>>>
I am using debian though and there is no debian package for graphviz itself, you have to install it with pip3.

Resources