I've installed python 3.4 on win7. I need faker module to be installed to run the script.
error:
from faker import Factory
ImportError: No module named 'faker'.
I've downloaded few zip's with faker, but unfortunately have no idea how to install it.
Please give simple instructions, how to make it work.(on windows)
Since you have downloaded the zip source from https://github.com/joke2k/faker according to your comments , you can also do the following after changing to the directory where you have setup.py -
python setup.py install
According to the github page itself, to install using pip do -
pip install fake-factory
Use the Python package tool pip.
Open a command prompt and do
pip install fake-factory
or
python -m pip install fake-factory
See the documentation for more information.
Related
Running kali 2020, I am trying to run CVE-2007-2447 which is a python2.7 script, which says:
import smb
from smb.SMBConnection import SMBConnection
I saved the script to a file and ran it, but I get ImportError: No module named smb. In the script, it says install pysmb by running pip install --user pysmb.
I did this, but still the same error message.
I tried to locate pysmb and found these packages:
$ locate pysmb
/usr/lib/python3/dist-packages/pysmbc-1.0.23.egg-info
/usr/lib/python3/dist-packages/pysmbc-1.0.23.egg-info/PKG-INFO
/usr/lib/python3/dist-packages/pysmbc-1.0.23.egg-info/dependency_links.txt
/usr/lib/python3/dist-packages/pysmbc-1.0.23.egg-info/top_level.txt
/usr/share/system-config-printer/pysmb.py
/usr/share/system-config-printer/__pycache__/pysmb.cpython-39.pyc
I have had a problem before where packages only install for python3 and I have to copy the folders to python2.7. I tried that for this without success.
When I googled module smb, it comes up with samba. I installed the samba package but still nothing. Does anyone know how I can get smb module to python2.7?
You need to install using the Python 2.7 pip. Use the following command:
pip2.7 install pysmb
Pip no longer supports Python 2.
pip documentation v21.0.1
You need to use python 2 pip to install the module, instead of installing it for python 3. See How to use pip with Python 3.x alongside Python 2.x
.
In my case, the problem was simple.
I named the python script file 'smb.py'. 'smb.py' and'pysmb' were in conflict.
I've installed a module named rauth through terminal with pip3 install rauth command but when I import the module and run the code on Visual Studio Code with python3 interpreter, it gives ModuleNotFoundError: No module named 'rauth' error. But it is indeed installed and I can use it in Anaconda. The package file is stored here.
/Users/puffedricecracker/anaconda3/lib/python3.7/site-packages/rauth
And it seems like all my pip installed packages are stored in that path, but those are imported outside Anaconda with no problem. Tried several other commands as google search suggested.
• pip install instead of pip3 install
• python -m pip install
• python3 -m pip install
Let me know if there is any other information needed to be specified.
this is due to the module is installed into site-packages in Anaconda but not Visual Studio. Can you check if the module exists in Visual Studio folder? Another way to test it is to open Python IDLE and run the import, it should also return an error.
I don't know if this could be an universal solution but there was a way to set where to install a package using pip.
In python shell, find where your python modules usually go. It seemed like most of pip installed packages were installed in the second path so I chose that.
>>> import re
>>> print(re.__file__)
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/re.py
>>> import sqlalchemy
>>> print(sqlalchemy.__file__)
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/sqlalchemy/__init__.py
Uninstall the package using pip uninstall packagename
Reinstall with a path name.
pip install packagename -t /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages
(In fact, just copy pasting package files (in my case, they were rauth, rauth-0.7.3.dist-info) from anaconda package path in the post worked.)
I am trying to edit some code that uses python-magic but I get an Import Error: No module called magic. Before I looked around the Internet and found advise on installing python-magic using pip which I did. I installed python-magic using pip install python-magic and also did pip install libarchive-c successfully.
when I try to do the import on the python shell. I am able to successfully as below;
But when I try to run code that uses this import statement I get an import error for missing magic module as below;
If anyone knows what is happening. Please help.
You have installed magic for Python 2.7, but Diffoscope uses Python 3 and explicitly recommends the package python3-magic in the repositories, which can be installed with sudo apt-get install python3-magic. Modules installed for Python 2.7 are not necessarily shared with Python 3, so you may need to install both versions if you need it for 2.7 as well.
On Ubuntu, you can run Python 3 with python3 and access Python 3's pip installation with pip3 to ensure that you are using the correct version.
I have installed both virtualenv and pywin32 on my Windows 7 64-bit laptop, and each of them seems to work, but not with each other.
More specifically, if a virtualenv is active, then running import win32com.client in a python interactive shell fails with No module named win32com.client. The same expression succeeds, however, if no virtualenv is active.
When I try to install pywin32 with pip (which is how I normally install modules when a virtualenv is active), I get the error:
Could not find any downloads that satisfy the requirement pywin32
No distributions at all found for pywin32
...even though pywin32 is one of the modules listed in the output of
pip search pywin32
Therefore, to install pywin32 at all I had to install it using an *.exe installer downloaded from SourceForge.
Is there any way to install pywin32 within a virtualenv?
UPDATE 2016
There is now a version of pywin32 on PyPI that can be installed with pip. It is called pypiwin32, and it installs the package using the binary wheel format.
https://pypi.python.org/pypi/pypiwin32
pip install pypiwin32
That will work in a virtualenv, or with tox, etc.
Below this line is my previous old answer. That is now outdated information.
OLD ANSWER - OUTDATED. Modern versions of virtualenv default to --no-site-packages. That means that not having access to global site-packages is now the default behavior.
Sadly, (as of July 2014) you can not pip install pywin32 in to your virtualenv. (here's the bug report)
If you want to get pywin32 running inside a virtualenv, activate the virtualenv and use easy_install and the pywin32 installer exe file. For example
easy_install "C:\Path\To\Downloads\pywin32-219.win32-py3.4.exe"
Related question
Try this:
Download directly
Enable your virtualenv
pip install --no-index --find-links:/local/dir/ SomePackage
Check out #8 on pip-installer.org (sorry no permalink)/
Create a virtualenv and activate it:
cd c:\Users\ernesto.luzon
virtualenv --no-site-packages py351env
py351env\Scripts\activate
From here, you have two options:
Download pywin32 from sourceforge project:
http://sourceforge.net/projects/pywin32/files/pywin32/
Download pywin32 from unofficial (but very helpful) binary site:
http://www.lfd.uci.edu/~gohlke/pythonlibs/#pywin32
Make sure you download the correct version for the Python Interpreter installed in your environment, otherwise you will encounter ImportError: DLL load failed: %1 is not a valid Win32 application later.
If you downloaded from sourceforge, install it using easy_install:
(py351env) C:\Users\ernesto.luzon\Downloads>easy_install pywin32-220.win-amd64-py3.5.exe
If you downloaded from gohlke, install it using pip:
(py351env) C:\Users\ernesto.luzon\Downloads>pip install pywin32-220-cp35-none-win_amd64.whl
In case you encounter ImportError: DLL load failed: The specified module could not be found error later on, you need these additional steps:
Run the post install script:
(py351env) C:\Users\ernesto.luzon>python py351env\Scripts\pywin32_postinstall.py -install
Copied pythoncom35.dll to C:\Users\ernesto.luzon\py351env\pythoncom35.dll
Copied pywintypes35.dll to C:\Users\ernesto.luzon\py351env\pywintypes35.dll
....
Notice where it copied the 'pythoncom35.dll' and 'pywintypes35.dll' files. You need to move these files to the folder:
C:\Users\ernesto.luzon\py351env\Lib\site-packages\win32
I am trying to run a python script that calls the yaml module on a server. I only have writing permissions in my home directory. The server has Python 2.7.3 installed. I do not have root access. Also, neither pip nor easy_install are available.
I have downloaded the package and tried to run
python setup.py install --user
which gives the error
error: can't combine user with with prefix/exec_prefix/home or install_(plat)base
How can I get this to work?
Setting up and using a virtualenv is almost always a good option and as you indicated you can download virtualenv.py, but that won't run (anymore) without pip being installed because it tries to install wheels. On Linux Mint with Python 2.7.6 the script e.g. throws:
OSError: Command /home/ruamel/venv/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools wheel failed with error code 1
You can probably circumvent that by using an older virtualenv.py.
In some other cases it is not feasible to use a virtualenv: e.g. when the system python has all kinds of libraries pre-installed that you need to use and cannot replicate into a local virtualenv. In that case you can download the latest version of ruamel.yaml (of which I am the author) and which is essentially a superset of the PyYAML functionality. When I forked the code I created a setup.py from scratch and it allows you to do
python setup.py install --user
without problem on the `setup.py extracted from the tar.gz file downloaded from PyPI.
Based on the idea of the answer by Anton, these steps worked for me
pip install --user ruamel.yaml
then replace in your script
import yaml
with:
from ruamel.yaml import YAML
yaml=YAML(typ='safe')