Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

difficulty importing nxviz in Python 3.6.5 #361

Closed
ghost opened this issue Jun 28, 2018 · 25 comments
Closed

difficulty importing nxviz in Python 3.6.5 #361

ghost opened this issue Jun 28, 2018 · 25 comments

Comments

@ghost
Copy link

ghost commented Jun 28, 2018

  • nxviz version: (unsure)
  • Python version: 3.6.5
  • Operating System: Windows 7 (using Jupyter Notebook through Anaconda)

Description

I am trying to visualize my data in a network, and so began working with the networkx module in Python 3.6.5. The import of networkx worked just fine, but when I attempted to import the nxviz module as well, I received an error message (see below).

What I Did

import nxviz as nv

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-2-870a416d29dd> in <module>()
----> 1 import nxviz as nv

ModuleNotFoundError: No module named 'nxviz'

Any help would be greatly appreciated!

@ericmjl
Copy link
Owner

ericmjl commented Jun 28, 2018

Hi @hansenzoe! Thanks for pinging in.

My first hunch is to check that nxviz has been installed into the correct environment. Can you paste the result of the following command in Jupyter?

import sys
sys.path

This will tell me where your Jupyter kernel is looking for packages.

@ghost
Copy link
Author

ghost commented Jun 28, 2018

Hi Eric! Thank you for getting back to me! Here is the output of the command:

import sys
sys.path

['',
'C:\Users\Zoe\Anaconda3\python36.zip',
'C:\Users\Zoe\Anaconda3\DLLs',
'C:\Users\Zoe\Anaconda3\lib',
'C:\Users\Zoe\Anaconda3',
'C:\Users\Zoe\Anaconda3\lib\site-packages',
'C:\Users\Zoe\Anaconda3\lib\site-packages\win32',
'C:\Users\Zoe\Anaconda3\lib\site-packages\win32\lib',
'C:\Users\Zoe\Anaconda3\lib\site-packages\Pythonwin',
'C:\Users\Zoe\Anaconda3\lib\site-packages\IPython\extensions',
'C:\Users\Zoe\.ipython']

@ericmjl
Copy link
Owner

ericmjl commented Jun 28, 2018

And just to check, are you working out of the "base" Anaconda environment, or are you using a separate conda environment?

@ghost
Copy link
Author

ghost commented Jun 28, 2018

I am using Anaconda Navigator to launch Jupyter Notebook on a server. (I'm not sure if that answers your question -- I'm fairly new to Python and programming, so I'm sorry for my ignorance!).

@ericmjl
Copy link
Owner

ericmjl commented Jun 28, 2018

@hansenzoe no worries! Welcome to the Python world 😄.

In a Jupyter cell, you can execute bash commands by prefixing them with an exclamation mark. The next command I'd like to see the output for is:

! conda list | grep nxviz  # this one if you installed nxviz by using conda.

As well as:

! pip list | grep nxviz  # this one if you installed nxviz by using pip

@ghost
Copy link
Author

ghost commented Jun 28, 2018

Thanks, Eric! Here is the output I receive (it seems that my Jupyter isn't recognizing the bash commands...).

! conda list | grep nxviz

'grep' is not recognized as an internal or external command,
operable program or batch file.

! pip list | grep nxviz

'grep' is not recognized as an internal or external command,
operable program or batch file.

@ericmjl
Copy link
Owner

ericmjl commented Jun 28, 2018

Oh yes, that's right, my bad -- grep is a Linux command.

Can you do:

! conda list

and see if "nxviz" is listed in the long list of things that comes out?

@ghost
Copy link
Author

ghost commented Jun 28, 2018

Running '! conda list' did not display "nxviz". Does this mean that it still needs to be installed somehow?

@ericmjl
Copy link
Owner

ericmjl commented Jun 28, 2018

Yes, that is right!

In your Jupyter notebook, you can do the following to install nxviz:

! conda install nxviz

Then try importing. If import nxviz as nv works, then make sure to delete the cell that contains the ! conda install nxviz command.

@ghost
Copy link
Author

ghost commented Jun 28, 2018

When I try running the "! conda install" command, I receive the following error:

Solving environment: ...working... failed

PackagesNotFoundError: The following packages are not available from current channels:

  • nxviz

Current channels:

Does this indicate that I need to access a different "channel" in order to find the correct package?

@ericmjl
Copy link
Owner

ericmjl commented Jun 28, 2018

Ah yes, that is right! Apologies, I had taken some settings for granted - I have configured my conda to automatically search conda-forge, which is where nxviz is located.

To get nxviz from conda-forge, use:

! conda install -c conda-forge nxviz

The -c flag tells conda to search the channel that is specified, in this case, conda-forge.

@ericmjl
Copy link
Owner

ericmjl commented Jun 28, 2018

Do let me know if it works, and if it does, don't forget to close the issue!

@ghost
Copy link
Author

ghost commented Jun 28, 2018

Hi Eric,
The install command has been running for quite some time (multiple hours), and my Kernel is still "busy". Does the install typically take this long? Luckily an error has not shown up yet, though!

@ericmjl
Copy link
Owner

ericmjl commented Jun 28, 2018

That definitely looks weird. What if you tried restarting your jupyter notebook server? That would mean closing everything, and shutting down the server in Anaconda Navigator.

@ericmjl
Copy link
Owner

ericmjl commented Jun 29, 2018

@hansenzoe do let me know how things are!

@ghost
Copy link
Author

ghost commented Jun 29, 2018

Hi Eric!
I haven't had any luck yet, but I will keep trying! Again, the kernel has been 'busy' trying to install nxviz for a number of hours. I'm not sure what the issue is?

@ericmjl
Copy link
Owner

ericmjl commented Jun 29, 2018

@hansenzoe this is beginning to look like an issue unrelated to nxviz, but for which I don't have a clear hypothesis. Installation for nxviz usually should take at most a few minutes on a reasonably modern computer; my experience in new environments is that it's been seconds to install. Windows users in my tutorials also have had few issues. I have also not used a Windows machine regularly for more than 13 years now, so I'm very out-of-date w.r.t. how to debug on Windows machines.

The hypotheses that I have below may be helpful for you to debug generally, but I doubt I'll be able to do more than list them out below. Hopefully, you have colleagues around you who might be more knowledgeable about your specific circumstances.

Hypothesis 1: Running the installation inside a Jupyter notebook doesn't work.

Proposed solution: run the installation command using the command prompt.

Hypothesis 2: Jupyter is hanging

Proposed solution: Kill the Jupyter server, and restart it. Failing that, restart computer.

Hypothesis 3: Jupyter and/or Anaconda installation is faulty (highly unlikely, but still a hypothesis)

Proposed solution: Remove Anaconda and reinstall it.

@ghost
Copy link
Author

ghost commented Jul 2, 2018

Thank you for the information, Eric! I appreciate you taking the time to help me, despite being unable to figure out the problem!

@ghost ghost closed this as completed Jul 2, 2018
@ericmjl
Copy link
Owner

ericmjl commented Jul 2, 2018

My pleasure, @hansenzoe! All the best in your debugging journeys.

@stonegz
Copy link

stonegz commented Oct 30, 2018

it's really strange, "import nxviz as nz" works fine in python command interface, but not in jupyter notebook.

Python 3.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 13:32:41) [MSC v.1900 64 bit (AMD64)]

@ericmjl
Copy link
Owner

ericmjl commented Oct 30, 2018

@stonegz welcome to the nxviz issue tracker!

From what I know, it's possibly because you don't have a Python kernel that Jupyter can recognize. To do this, you have to install the kernel:

$ conda activate <your_env_name_no_brackets>
$ python -m ipykernel install --user --name <your_env_name_no_brackets>

@stonegz
Copy link

stonegz commented Oct 31, 2018

Thanks, Eric. Yup, as you guess, the problem is i have two python installations, the default to jupyter is not the one i installed nxviz.
It's been fixed by
conda install jupyter.

@PyMap
Copy link

PyMap commented May 12, 2019

Hi Eric. I´m having the same issue as @hansenzoe! . I´m trying to install nxviz with python 3.6 on jupyter notebook (Windows 10). This is a virtual environment (the root is python 2.7). Using "!pip install nxviz" on jupyter I get the following error:

ERROR: Cannot uninstall 'PyYAML'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

When I try with "! conda install nxviz" or "! conda install -c conda-forge nxviz" (from notebook or the anaconda prompt of the virtual environment) the instalation process never ends.

Do you any idea?

Thanks!

@saurabhiitg
Copy link

Hi Eric. I´m having the same issue as @hansenzoe! . I´m trying to install nxviz with python 3.6 on jupyter notebook (Windows 10). This is a virtual environment (the root is python 2.7). Using "!pip install nxviz" on jupyter I get the following error:

ERROR: Cannot uninstall 'PyYAML'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

When I try with "! conda install nxviz" or "! conda install -c conda-forge nxviz" (from notebook or the anaconda prompt of the virtual environment) the instalation process never ends.

Do you any idea?

Thanks!

Try
pip install nxviz--ignore-installed PyYAML
Reference and real problem: pypa/pip#5247 (comment)

@Mafaldim
Copy link

Hi @ericmjl, @saurabhiitg

I had the same problem with @hansenzoe, I managed to overcome the problem after updating Anaconda navigator and trying conda install nxviz or conda install -c conda-forge nxviz .

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants