I am attempting to run the following code which I received from samples here
from __future__ import print_function
import atexit
from pyVim.connect import SmartConnectNoSSL, Disconnect
from pyVmomi import vim
from tools import cli
I am receiving the following error:
ModuleNotFoundError: No Module named 'pyVim.connect'
The packages in question are from here and were installed using:
pip install pyvmomi
Is there something wrong with how I am installing these packages?
Looks like the code was a bit old. Importing 'pyvim' instead of 'pyVim' worked, though it seems to be named 'pyVim' on the github.
It's possible that you need to reinstall pvmomi to force the re-install of additional files in the pyVim/ package dir:
pip3 install --force pyvmomi
I haven't figured out how or what causes this, but the issue seems to occur on case-insensitive macOS file systems.
Since it has different behavior than Linux and case-sensitive macOS, I use the following "hack" to make it compatible between systems:
try:
from pyVim.connect import SmartConnectNoSSL
except ImportError:
from pyvim.connect import SmartConnectNoSSL
PS: You can use diskutil info / on macOS to figure out if your file system is case-sensitive or not (Details in another StackExchange question)
Related
A Python script starts with:
from pathlib import Path
import sqlite3
which I read as an initialization of Libraries needed to run the rest of the script. However if the following error is returned in the terminal:
ImportError: No module named pathlib
I am uncertain how to interpret this. One assumption is that the pathlib library is uninstalled. However on the local system Python 2.7 and Python 3.4 are installed (I believe one was system pre-installed).
How can a library be asserted to exist? In case it is missing, how can it be installed?
You have to install it first
pip install pathlib
And with that your code should work.
I am new to Python and Pycharm and in my project (Python 2.7) I am trying to launch some code which uses zmq as a dependency. I installed zmq through package manager and added manually some paths to env. Currently it looks like the following:
But when I run the script in fails with the following message: from . import
(constants, error, message, context,
ImportError: DLL load failed: Не найден указанный модуль.
So it looks like this:
so basically it is the first line of code which generates this error:
import os, sys, time, signal, zmq
Any ideas how to fix it would be welcome. Thank you
I suppose I have Cython as when I try to install it I see the following:
pyzmq is also present:
issue solved.
just installed pure Python 2.7 interpreter from https://www.python.org/ and added it as an interpreter in PyCharm, Also installed protobuf and pyzmq there and it worked. I think it was an Anaconda issue, although I removed zmq module from there leaving only pyzmq.
I am used to see import errors of my own modules.
But this time, this is about modules installed via pip and located in site-packages.
Here is a test file expurged from everything but just the imports :
import flask
import pygments
from flask_restful import Resource, Api
#from weather_tool import *
#from flask_restless import *
while running pytest :
Traceback:
test_MonAPPflaskRest.py:3: in <module>
from flask_restful import Resource, Api
E ModuleNotFoundError: No module named 'flask_restful'
Actually, every module with an underscore will fail !!!
flask_restless will fail to import to.
But it work when executed outside of pytest, or simply on the python shell...
Ok, I went through it.
Actually, Anaconda was installed. From here, no problem with that.
I installed Python from source as I'm used to do on a Linux platform and it works normally as expected.
I found out that pytest was not is the list of packages installed via pip.
Seems Anaconda provides a default pytest install. Maybe something is wrong with this version. (which pytest will return a pystest file in the python bin directory.
Actually, a simple pip install pytest in your virtualenv will 'overwrite' this - maybe messy - pytest version.
However calling pytest won't still work. You have to user py.test.
I know this is pretty much empirical. But that's it...
I got a similar error while importing stocker (Unable to find stocker module).
Try adding your 'code directory' to 'sys.path' where python looks for modules and it should be able to import then.
For more details:
https://bic-berkeley.github.io/psych-214-fall-2016/sys_path.html
I used the code:
>>> import sys
>>> sys.path.append('code') # code = the directory where your module is saved
>>> # Now the import will work
>>> import a_module # a_module = the module you are trying to import
I also faced the same issue when installed in virtual environment. I've deactivated virtual environment, installed flask-restful from PIP and then activated virtual environment. The issue is resolved.
I want to import the paramiko module located in /usr/local/lib/python2.7/dist-packages. So, I imported it this way:
from usr.local.lib.python2.7.dist-packages import paramiko
I have an error syntax related to python2.7 (It considers 7 as a package located in python2 package)
I have both Python3.1.3 and Python2.7 installed. I program with Python3.1.3 only, however.
How can I resolve this problem ?
How about ?
import sys
sys.path.append('/usr/local/lib/python2.7/dist-packages')
import paramiko
UPDATED
The best solution is installing paramiko on Python3 env. Take a look at #DanielRoseman's answer. Or virtualenv is worth consideration. Here is a good tutorial. http://simononsoftware.com/virtualenv-tutorial/
I don't know why you think you need to include the full path. That directory will already be included in the Python path. You just need to do import paramiko.
Edit after comment Well you can't randomly import things that are installed for a different version. There are several backwards incompatibilities, and anything that has any compiled extensions will just not work at all.
You need to download and install paramiko for your 3.1 installation, rather than trying to use the 2.7 version. python3 pip install paramiko, as an example.
(Also, you shouldn't really be using 3.1. If you're using the Python 3 series you should upgrade to 3.4.)
I am new to python and just tried to import the live streamer module (http://livestreamer.readthedocs.org/en/latest/api.html) in Python.
The module is installed at:
/Library/Python/2.7/site-packages/livestreamer-1.8.0-py2.7.egg
My script is pretty much one line:
from livestreamer import Livestreamer
Error:
ImportError: cannot import name Livestreamer
I searched the web for similar issues, but couldn't find any related to this module, but apparently it's a circular dependent import...? I don't know how to fix this.
Note: My script works when it's just:
import livestreamer
I'd say the modules doesn't contain a class called Livestreamer, but the documentation says so.
Did you properly installed Livestreamer.? R u experienced any error ..?
Try running this command from the package
pip install setup.py