Installing Network-x - networkx

How do I download and install network-x for python version 3.4.0 on mac? Can someone give me a step by step guide on installing network-x? I tried to quick 'quick install' as suggested by github.
When I try to import it on python it gives me an import error saying no modules were found.

Ok so I have figured out an easier way:
(Answering my own question)
I first download the networkx-1.10.zip (md5) zip file from https://pypi.python.org/pypi/networkx. Unzipped it. Opened the terminal and typed cd
Then, I dragged and dropped the unzipped folder (networkx-1.10) into the terminal. Hit Enter.
Then I proceeded with the following commands:
python3 --version
ls
umask
sudo python setup.py install
sudo python3 setup.py install
python3
It worked like a charm.

this has worked for me
sudo pip install networkx

This should work:
sudo pip3 install networkx

if you have annaconda, in your terminal or cmd
> % conda install -c anaconda networkx
> % conda install -c anaconda graphviz
> % conda install -c anaconda pydot
> % conda install -c pdrops pygraphviz
The other packages come in handy as well

The easiest way is using Anaconda, since networkX is installed by default. Just follow the instructions on their website (they have both a graphical and command line installer).

Related

Installing python modules in vs code not working

i am trying to install some module like: "praw" and "discord" but after using this command: pip install praw in vs code's terminal and after when i run the file, i got a error saying that No module named 'praw' i have searched the entire internet that how to install a module in vs code and about this error. pls help if you know.
Thanks
If you have python3 you could try py -3 -m pip install praw or python3 -m pip install praw
edit: If this doesn't works in vscode then try running cmd as admin.

Pip installing packages but module not found after install

Hi I am running Ubuntu 16.04.
I have had problems with my pip, it seems like it is installing correctly but when I open python and go to import, it gives me an error saying it cannot be found.
I read other posts and it seems like pip is talking to the wrong version of python.
When I run:
>> which pip
/home/Username/.local/bin/pip
>> which python
/usr/bin/python
I tried uninstalling pip and then reinstalling it but when I run "which pip" it comes up the same location. I can't use this pip to download any python packages. Does anyone have any idea how to fix this?
Edit:
When i put in the terminal the following commands the output is:
>> python -V
Python 2.7.12
>> pip -V
pip 9.0.1 from /home/heatdeath/.local/lib/python2.7/site-packages (python 2.7)

cannot activate virtualenv: No such file or directory

I have problem with activating virtualenv.
I'm working on the server and using SSH secure shell.
My final goal is to activate virtualenv and run the latest version of tensorflow
The following is the command lines:
jeonguyoang#vision6:~$ python3 -m venv tfenv
The virtual environment was not created successfully because ensurepip is not
available. On Debian/Ubuntu systems, you need to install the python3-venv
package using the following command.
apt-get install python3-venv
You may need to use sudo with that command. After installing the python3-venv
package, recreate your virtual environment.
jeonguyoang#vision6:~$ source tfenv/bin/activate
-bash: tfenv/bin/activate: No such file or directory
jeonguyoang#vision6:~$ cd tfenv
jeonguyoang#vision6:~/tfenv$ ls
bin include lib lib64 pyvenv.cfg
jeonguyoang#vision6:~/tfenv$ cd bin
jeonguyoang#vision6:~/tfenv/bin$ ls
python python3
captured image of the commands
I think that there is no activate file.
Maybe re-installing virtualenv is the answer, but I cannot interrupt server settings..
Check if you have python 2 versions of pip and python (python-all & python-pip packages). Venv installs both v2 and v3 versions of python & pip (regardless of python version of venv).

How can I make a list of installed packages in a certain virtualenv?

You can cd to YOUR_ENV/lib/pythonxx/site-packages/ and have a look, but is there any convenient ways?
pip freeze list all the packages installed including the system environment's.
You can list only packages in the virtualenv by
pip freeze --local
or
pip list --local.
This option works irrespective of whether you have global site packages visible in the virtualenv.
Note that restricting the virtualenv to not use global site packages isn't the answer to the problem, because the question is on how to separate the two lists, not how to constrain our workflow to fit limitations of tools.
Credits to #gvalkov's comment here. Cf. also pip issue 85.
Calling pip command inside a virtualenv should list the packages visible/available in the isolated environment. Make sure to use a recent version of virtualenv that uses option --no-site-packages by default. This way the purpose of using virtualenv is to create a python environment without access to packages installed in system python.
Next, make sure you use pip command provided inside the virtualenv (YOUR_ENV/bin/pip). Or just activate the virtualenv (source YOUR_ENV/bin/activate) as a convenient way to call the proper commands for python interpreter or pip
~/Projects$ virtualenv --version
1.9.1
~/Projects$ virtualenv -p /usr/bin/python2.7 demoenv2.7
Running virtualenv with interpreter /usr/bin/python2.7
New python executable in demoenv2.7/bin/python2.7
Also creating executable in demoenv2.7/bin/python
Installing setuptools............................done.
Installing pip...............done.
~/Projects$ cd demoenv2.7/
~/Projects/demoenv2.7$ bin/pip freeze
wsgiref==0.1.2
~/Projects/demoenv2.7$ bin/pip install commandlineapp
Downloading/unpacking commandlineapp
Downloading CommandLineApp-3.0.7.tar.gz (142kB): 142kB downloaded
Running setup.py egg_info for package commandlineapp
Installing collected packages: commandlineapp
Running setup.py install for commandlineapp
Successfully installed commandlineapp
Cleaning up...
~/Projects/demoenv2.7$ bin/pip freeze
CommandLineApp==3.0.7
wsgiref==0.1.2
What's strange in my answer is that package 'wsgiref' is visible inside the virtualenv. Its from my system python. Currently I do not know why, but maybe it is different on your system.
In Python3
pip list
Empty venv is
Package Version
---------- -------
pip 19.2.3
setuptools 41.2.0
To create a new environment
python3 -m venv your_foldername_here
Activate
cd your_foldername_here
source bin/activate
Deactivate
deactivate
You can also stand in the folder and give the virtual environment a name/folder (python3 -m venv name_of_venv).
Venv is a subset of virtualenv that is shipped with Python after 3.3.
list out the installed packages in the virtualenv
step 1:
workon envname
step 2:
pip freeze
it will display the all installed packages and installed packages and versions
If you're still a bit confused about virtualenv you might not pick up how to combine the great tips from the answers by Ioannis and Sascha. I.e. this is the basic command you need:
/YOUR_ENV/bin/pip freeze --local
That can be easily used elsewhere. E.g. here is a convenient and complete answer, suited for getting all the local packages installed in all the environments you set up via virtualenvwrapper:
cd ${WORKON_HOME:-~/.virtualenvs}
for dir in *; do [ -d $dir ] && $dir/bin/pip freeze --local > /tmp/$dir.fl; done
more /tmp/*.fl
why don't you try pip list
Remember I'm using pip version 19.1 on python version 3.7.3
If you are using pip 19.0.3 and python 3.7.4. Then go for pip list command in your virtualenv. It will show all the installed packages with respective versions.
.venv/bin/pip freeze worked for me in bash.
In my case the flask version was only visible under so I had to go to
C:\Users\\AppData\Local\flask\venv\Scripts>pip freeze --local
Using python3 executable only, from:
Gitbash:
winpty my_venv_dir/bin/python -m pip freeze
Linux:
my_venv_dir/bin/python -m pip freeze

scipy missing libifport.so.5

I am trying to install scipy 0.10.1 on Ubuntu 10.10 using pip.
I have successfully installed numpy:
$ sudo pip install --upgrade numpy
[snip]
Successfully installed numpy
Cleaning up...
but when I try scipy I get:
$ sudo pip install --upgrade scipy
[snip]
File "/usr/local/lib/python2.6/dist-packages/numpy/linalg/linalg.py", line 23, in <module>
from numpy.linalg import lapack_lite
ImportError: libifport.so.5: cannot open shared object file: No such file or directory
I do have libifport.so.5, but I don't know why the installer isn't finding it.
$ echo $LD_LIBRARY_PATH
:/opt/intel/composerxe-2011.2.137/compiler/lib/intel64
I have also tried to install several other packages in the hope that one of them might help (e.g. libatlas-base-dev liblapack-dev libatlas-base-dev liblapack-dev, etc)
Any thoughts?
Thank you.
Most likely you have not defined the LD_LIBRARY_PATH for root. To check this:
$ sudo su
$echo $LD_LIBRARY_PATH
You can specify environment variables as follows:
$ sudo env LD_LIBRARY_PATH=path/to/compiler' pip install scipy
Check out this blog post to create an alias to save you typing each time:
http://final-world-domination.blogspot.ch/2011/02/sudo-doesnt-export-ldlibrarypath.html
This fixed the problem for me on Debian 9:
conda install -c intel -c conda-forge -c pytorch --override-channels intel-fortran-rt
# find / -iname "libifport*"
./opt/conda/lib/libifport.so
./opt/conda/lib/libifport.so.5
./opt/conda/pkgs/intel-fortran-rt-2021.3.0-intel_3350/lib/libifport.so
./opt/conda/pkgs/intel-fortran-rt-2021.3.0-intel_3350/lib/libifport.so.5