Can't activate anaconda environment on CentOS - centos

I'm working on install tensorflow on my CentOS system.
I had success install miniconda in my system and created tensorflow environment.
However, I got error message while I run "source activate tensorflow".
I checked on Anaconda page and found out the reason is activate file only support bash and zsh. But my OS centOS is csh (C shell).
And I also try to add "set path " for the tensorflow environment on my ~/.cshrc file. But it looks not working, I still get ImportError while I import tensorflow.
Does anyone know how to solve this problem?

You can try the following (on CentOS 6.8 or CentOS 7):
[root#9dc1f60d1dcd ~]# csh
[root#9dc1f60d1dcd ~]# echo $0
csh
[root#9dc1f60d1dcd ~]# bash Miniconda2-4.3.11-Linux-x86_64.sh -b -p /m2
[root#9dc1f60d1dcd ~]# /m2/bin/conda install -y tensorflow
[root#9dc1f60d1dcd ~]# /m2/bin/python
Python 2.7.13 |Continuum Analytics, Inc.| (default, Dec 20 2016, 23:09:15)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import tensorflow
>>> tensorflow.__version__
'0.10.0rc0'

Related

/usr/bin/python is needed by rpm

I am trying to install a rpm with a python script and I see this following error
error: Failed dependencies:
/usr/bin/python is needed by smartnav-3.24-1.0.002.noarch
libnsl.so.1()(64bit) is needed by smartnav-3.24-1.0.002.noarch
but i can find python3.7 in /usr/bin
/usr/bin/python
Python 3.7.1 (default, Feb 6 2023, 06:40:16)
[GCC 8.5.0 20210514 (Red Hat 8.5.0-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
it is a RHEL Linux environment
I tried symbolic linking but didnt help
I could install with --nodeps, but I dont want to use this flag

python virtualenv failure after upgrade fedora from 31 to 33

When I upgraded fedora from 31 to 33, I found out that the base python package had been upgraded from 3.7.9 to 3.9, and that python references in virtual environment folders were now pointing to the new version of python.
There were no problems activating my python 3.7 virtual environment
[bou#bous-fed33 avguide]$ source ~/py37/bin/activate
(py37) [bou#bous-fed33 avguide]$ which python
~/py37/bin/python
However the python version was no longer 3.7.9 but 3.9, which came with fedora 33
(py37) [bou#bous-fed33 avguide]$ python -V
Python 3.9.0
Now when I tried running jupyter notebook get errors ModuleNotFoundError
(py37) [bou#bous-fed33 avguide]$ jupyter notebook --port 7777
[W 09:14:02.710 NotebookApp] Error loading server extension jupyterlab
ModuleNotFoundError: No module named 'jupyterlab'
Also get errors for other packages like pandas, numpy etc which had all been fine before.
(py37) [bou#bous-fed33 avguide]$ python
Python 3.9.0 (default, Oct 6 2020, 00:00:00)
[GCC 10.2.1 20200826 (Red Hat 10.2.1-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas as ps
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pandas'
I had tried to reinstall all the packages from existing requirements.txt file and manual reinstalls as well - all failed with errors. There was also no point in reinstalling python 3.7 as it was still there.
(py37) [bou#bous-fed33 avguide]$ pip3 install --force-reinstall -r requirements.txt
[bou#bous-fed33 avguide]$ sudo dnf install python37
Package python3.7-3.7.9-2.fc33.x86_64 is already installed.
I found a relatively simple FIX after a while.
The way python versions is managed is by using symbolic links in virtual env folders. So all we have to do is find the location of existing python binary for 3.7.9 or whatever python version your virtual environment uses and update the symbolic links to point to the correct python base packages.
These are the python versions installed in my fedora OS/base.
[bou#bous-fed33 ~]$ ls -ltr /usr/bin/python3*
-rwxr-xr-x. 2 root root 15536 Sep 22 19:23 /usr/bin/python3.7
-rwxr-xr-x. 1 root root 15536 Sep 25 23:37 /usr/bin/python3.8
lrwxrwxrwx. 1 root root 9 Oct 7 00:19 /usr/bin/python3 -> python3.9 <<<
-rwxr-xr-x. 1 root root 15536 Oct 7 00:20 /usr/bin/python3.9 <<<
Note how /usr/bin/python3 points to python3.9
Locate the symbolic links in virtual environment ~/py37/bin/ folder
[bou#bous-fed33 avguide]$ cd ~/py37/bin/
[bou#bous-fed33 bin]$ ls -ltr python*
lrwxrwxrwx. 1 bou bou 16 Dec 29 2019 python3 -> /usr/bin/python3
lrwxrwxrwx. 1 bou bou 7 Dec 29 2019 python -> python3
Note how python points to python3 and python3 in turn points to operating system package /usr/bin/python3 - which after the fedora python upgrade no longer points to /usr/bin/python3.7 but to the new version of python /usr/bin/python3.9
So all we need to do is remove existing softlinks
[bou#bous-fed33 bin]$ rm python3 python
And then create new files or symbolic links python3 and python that point to python3.7 binary in /usr/bin/python3.7
[bou#bous-fed33 bin]$ ln -s /usr/bin/python3.7 python3
[bou#bous-fed33 bin]$ ln -s python3 python
Activate virtual environment and check python version is correct.
[bou#bous-fed33 bin]$ ls -ltr python*
lrwxrwxrwx. 1 bou bou 18 Dec 2 10:03 python3 -> /usr/bin/python3.7
lrwxrwxrwx. 1 bou bou 7 Dec 2 10:04 python -> python3
[bou#bous-fed33 avguide]$ source ~/py37/bin/activate
(py37) [bou#bous-fed33 avguide]$ python -V
Python 3.7.9
(py37) [bou#bous-fed33 avguide]$ which python
~/py37/bin/python
(py37) [bou#bous-fed33 avguide]$ python
Python 3.7.9 (default, Sep 22 2020, 09:19:36)
[GCC 10.2.1 20200826 (Red Hat 10.2.1-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas as pd
>>> quit()
We got the correct python version back for our virtual env and JupyterLab runs all right as well now.
(py37) [bou#bous-fed33 avguide]$ jupyter notebook --port 7777
[I 10:07:54.408 NotebookApp] JupyterLab extension loaded from /home/bou/py37/lib64/python3.7/site-packages/jupyterlab
[I 10:07:54.408 NotebookApp] JupyterLab application directory is /home/bou/py37/share/jupyter/lab
[I 10:07:54.410 NotebookApp] The Jupyter Notebook is running at:
[I 10:07:54.410 NotebookApp] https://bous-fed33:7777/
Hope this helps out someone running into similar problems with using their python virtual environment after base OS and/or python upgrade to a new version.
A better solution is to use pyenv, as it is specifically designed for this situation.
Pyenv will be available in your package repo... so yum search pyenv, then install.
See all available Python versions that pyenv can install for you:
$ pyenv install --list
Then pick form the list, eg. you'll see your missing Python 3.7.9. Install it to your local pyenv store, which will allow you to use it in your virtual environment:
$ pyenv install 3.7.9
You can then activate it in the directory containing your virtual env:
$ cd avguide
$ python --version
Python 3.9.0
$ pyenv local 3.7.9
$ python --version
Python 3.7.9
and it will automatically take care of you python binary links. See this tutorial and search for similar ones to get all the details.

Visual Studio Code and pylint not finding module issues

First, I may have more of an issue with correct environment selection. I did a fresh install of Linux Mint 19 and apt dist-upgrade... etc... and then used apt-get and pip to install pymysql, pil.intertk and pylint for both python and python3 from the cli...
All is good from cli:
~$ python3 --version
Python 3.6.5
~$ pylint3 --version
No config file found, using default configuration
pylint3 1.8.3,
astroid 1.6.0
Python 3.6.5 (default, Apr 1 2018, 05:46:30)
[GCC 7.3.0]
python3
Python 3.6.5 (default, Apr 1 2018, 05:46:30)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pymysql
>>> import PIL
>>>
After installing VSC.... the only two selection of python environments are 2.7.12 and 3.5.2 ?
I then modified VSC settings with: "python.pythonPath": "/usr/bin/python3"
Which still shows as Python 3.5.2 64-bit within VSC
But here comes my issue that I have tried many suggestions I have found from searching with no luck...
pylint is not finding any module I install. I assume its due to the mix match of version ? But not sure how to resolve that?
When I try to specify the pylint path : "python.linting.pylintPath": "/usr/bin/pylint3"
I get an invalid path error in VSC.. but its a valid path
~$ which pylint3
/usr/bin/pylint3
Any help would be greatly appreciated....
So after some frustrating trail and error I have fixed the issue by uninstalling the Flatpak version of Visual Studio Code listed in the Linux Mint's Software Center... and installing the deb package from the official site.
After installing the deb package... the proper version of python are showing and pylint is working correctly.

python's readline module not available for windows?

Granted I've been off PYTHON for two + years. I'm trying to get back into the swing, and I remember having command and variable completion available on windows a few years back. We were stuck in 2.6 as we had dependencies.
Today, I'm trying to import readline. I get this message from pip.
C:\Users\Joe>pip3 install readline
Collecting readline
Using cached https://files.pythonhosted.org/packages/f4/01/2cf081af8d880b44939a5f1b446551a7f8d59eae414277fd0c303757ff1b/readline-6.2.4.1.tar.gz
Complete output from command python setup.py egg_info:error: this module is not meant to work on Windows
my version is:
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 readline
Traceback (most recent call last):
File "", line 1, in
ModuleNotFoundError: No module named 'readline'
I have recently faced the same issue on Windows 10. readline is not available for Windows, however there is pyreadline3 (a continuation of the abandoned pyreadline package) which is for windows and you may try it.
Try to install pyreadline3 and use it instead of readline:
pip: pip install pyreadline3 or python -m pip install pyreadline
mamba: mamba install -c conda-forge pyreadline3
conda: conda install -c conda-forge pyreadline3
Then, in your python file do this:
from pyreadline3 import Readline
readline = Readline()
That way, you can use readline in Windows like in linux systems.
Go to your CMD terminal and type
pip install pyreadline
with in few seconds it will be installed and you will be able to see message i.e. "Successfully installed pyreadline-"
then go back to your PYSPARK terminal and type again import readline
it will import now without any error
Thanks
I tried pyreadline after finding this question and had problems and eventually found that it is no longer supported.
What worked for me was installing pyreadline3 with:
pip install pyreadline3

Draw networkx graph with pygraphviz on Mac 10.10

so I am trying to draw the graph I already have and I constantly run to an error I do not understand.
File "/usr/local/lib/python2.7/site-packages/pygraphviz/agraph.py", line 1305, in layout
data=self._run_prog(prog,' '.join([args,"-T",fmt]))
File "/usr/local/lib/python2.7/site-packages/pygraphviz/agraph.py", line 1251, in _run_prog
runprog=r'"%s"'%self._get_prog(prog)
File "/usr/local/lib/python2.7/site-packages/pygraphviz/agraph.py", line 1239, in _get_prog
raise ValueError("Program %s not found in path."%prog)
ValueError: Program dot not found in path.
But I have installed graphviz with brew and my path works:
Computer:~ name$ dot -V
dot - graphviz version 2.38.0 (20140413.2041)
So what is wrong?
Why is the program not found? Thanks!
to draw it i do like this
A=nx.to_agraph(graph) # convert to a graphviz graph
A.layout(prog='dot') # neato layout
A.draw(filename+'.png') # write
I've got a similar setup to you (Mac OSX 10.10, brew) and it is working for me.
e.g.
aric:~ aric$ python
Python 2.7.6 (default, Sep 9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import networkx as nx
>>> A = nx.to_agraph(nx.path_graph(4))
>>> A
<AGraph path_graph(4) <Swig Object of type 'Agraph_t *' at 0x10dbd9600>>
>>> print A
strict graph "path_graph(4)" {
0 -- 1;
1 -- 2;
2 -- 3;
}
>>> A.layout(prog='dot')
>>> A.draw('foo.png')
>>>
aric:~ aric$ brew -v
Homebrew 0.9.5
aric:~ aric$ uname -a
Darwin aric.local 14.0.0 Darwin Kernel Version 14.0.0: Fri Sep 19 00:26:44 PDT 2014; root:xnu-2782.1.97~2/RELEASE_X86_64 x86_64
Maybe something is wrong with your pygraphviz install?
Try
$ python setup_egg.py test
from the pygraphviz source directory and see if it passes.
You might need to
$pip install doctest-skip-unicode
$pip install nose
OK found it digging!
It is eclipse fault and PyDev.
And to be exact, the lack of your $PATH in eclipse settings.
Useful links:
OSX + Eclipse + PyDev - PATH isn't correct
Environment variables in Mac OS X
for me worked:
launchctl setenv PATH $PATH
and restart eclipse. you would have to do it everytime you reboot.
unfortunately it is an apple bug and you can not do much about it.
The other way round is:
ln -s /Applications/eclipse/Eclipse.app/Contents/MacOS/eclipse /usr/local/bin/eclipse
and then start eclipse from terminal:
eclipse &
and the PATH variable will be OK. :(