Python - No module named 'fabric.api - Windows 10 - python

I just installed Python 3.7 and Fabric.
It works perfectly on my laptop, but not on my desktop.
The error :
Traceback (most recent call last):
File "C:\Program Files (x86)\Python37-32\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Program Files (x86)\Python37-32\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\python_project\myProject\env\Scripts\fab.exe\__main__.py", line 9, in <module>
File "c:\python_project\myProject\env\lib\site-packages\invoke\program.py", line 352, in run
self.parse_collection()
File "c:\python_project\myProject\env\lib\site-packages\invoke\program.py", line 444, in parse_collection
self.load_collection()
File "c:\python_project\myProject\env\lib\site-packages\fabric\main.py", line 82, in load_collection
super(Fab, self).load_collection()
File "c:\python_project\myProject\env\lib\site-packages\invoke\program.py", line 661, in load_collection
module, parent = loader.load(coll_name)
File "c:\python_project\myProject\env\lib\site-packages\invoke\loader.py", line 76, in load
module = imp.load_module(name, fd, path, desc)
File "C:\Program Files (x86)\Python37-32\lib\imp.py", line 235, in load_module
return load_source(name, filename, file)
File "C:\Program Files (x86)\Python37-32\lib\imp.py", line 172, in load_source
module = _load(spec)
File "<frozen importlib._bootstrap>", line 696, in _load
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\python_project\myProject\fabfile.py", line 2, in <module>
from fabric.api import task, run, env, settings, hide
ModuleNotFoundError: No module named 'fabric.api'
But Fabric seem to be installed ?
C:\Users\MyUser>pip install fabric
Requirement already satisfied: fabric in c:\program files (x86)\python37 32\lib\site-packages (2.4.0)
C:\Users\MyUser>pip show fabric
Name: fabric
Version: 2.4.0
Summary: High level SSH command execution
Home-page: http://fabfile.org
Author: Jeff Forcier
Author-email: jeff#bitprophet.org
License: BSD
Location: c:\program files (x86)\python37-32\lib\site-packages
Requires: paramiko, cryptography, invoke
Required-by:
However "fabric" didn't appear in the list when I do the following in idle (just Fabfile) :
>>> import pkgutil
>>> [name for _, name, _ in pkgutil.iter_modules()]
['fabfile', '_asyncio', '_bz2', ... 'enum', 'filecmp', 'fileinput', ...]
I also tried to uninstall/reinstall fabric, but it's still failing.
Do you have any idea why I cannot import fabric.api ?
Update :
I also created a virtual environment :
py -3 -m venv env
code .
Selected Python interpreter "venv" in Visual Studio code then :
python -m pip install fabric
But i'm still facing the same error :-/

Well after few research I finally found a workaround by using fabric3 (a fork of Fabric, compatible python 3).
pip uninstall fabric
pip install fabric3
Link : https://pypi.org/project/Fabric3/

I see you have already installed fabric 2.4.0 which is great! Since you are using the fabric 2.4.0 you can't use from fabric.api import taks. fabric.api could be used if you use fabric1xx
If you want to import connection and task from fabric2.4.0 you have to do it like this
from fabric import Connection as connection, task
#task
def deploy(ctx):
with connection(host=host, user=user) as c:
c.run('ls -la')
Note: fabric 3 is not an official fork. I advise you to use fabric2.4.0

Related

How to install pgadmin4 on Ubuntu

I am trying to install pgadmin4 on ubuntu vps server but i am unable to install . I am getting this error
postgres version 12.2
ubuntu version 18.04
unable to figure out this error , any help would be appreciated tried everything but didnot worked
Setting up pgadmin4-apache2 (4.18-1.pgdg18.04+1) ...
apache2_invoke pgadmin4: already enabled
Traceback (most recent call last):
File "setup.py", line 413, in <module>
setup_db()
File "setup.py", line 347, in setup_db
app = create_app()
File "/usr/share/pgadmin4/web/pgadmin/__init__.py", line 400, in create_app
driver.init_app(app)
File "/usr/share/pgadmin4/web/pgadmin/utils/driver/__init__.py", line 40, in init_app
DriverRegistry.load_drivers()
File "/usr/share/pgadmin4/web/pgadmin/utils/driver/registry.py", line 88, in load_drivers
module = import_module(module_name)
File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/usr/share/pgadmin4/web/pgadmin/utils/driver/psycopg2/__init__.py", line 28, in <module>
from .server_manager import ServerManager
File "/usr/share/pgadmin4/web/pgadmin/utils/driver/psycopg2/server_manager.py", line 30, in <module>
from sshtunnel import SSHTunnelForwarder, BaseSSHTunnelForwarderError
File "/usr/lib/python3/dist-packages/sshtunnel.py", line 25, in <module>
import paramiko
File "/usr/lib/python3/dist-packages/paramiko/__init__.py", line 30, in <module>
from paramiko.transport import SecurityOptions, Transport
File "/usr/lib/python3/dist-packages/paramiko/transport.py", line 66, in <module>
from paramiko.sftp_client import SFTPClient
File "/usr/lib/python3/dist-packages/paramiko/sftp_client.py", line 41, in <module>
from paramiko.sftp_file import SFTPFile
File "/usr/lib/python3/dist-packages/paramiko/sftp_file.py", line 66
self._close(async=True)
^
SyntaxError: invalid syntax
dpkg: error processing package pgadmin4-apache2 (--configure):
installed pgadmin4-apache2 package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
pgadmin4-apache2
E: Sub-process /usr/bin/dpkg returned an error code (1)
Solution for me was explicitly install package python3-paramiko:
apt-get install python3-paramiko
Resulted in:
Preparing to unpack .../python3-paramiko_2.6.0-2_all.deb ...
Unpacking python3-paramiko (2.6.0-2) over (2.0.0-1ubuntu1.2) ...
Setting up python3-bcrypt (3.1.7-2ubuntu1) ...
Setting up python3-cryptography (2.8-3ubuntu0.1) ...
Setting up pgadmin4-apache2 (4.25-1.pgdg20.04+1) ...
pgAdmin 4 - Application Initialisation
======================================
Setting up python3-nacl (1.3.0-5) ...
Setting up python3-paramiko (2.6.0-2) ...
Happened during release upgrade from 18.04 to 20.04. Error traceback was the same.
from pgadmin website:
Setup the repository
Install the public key for the repository (if not done previously):
sudo curl https://www.pgadmin.org/static/packages_pgadmin_org.pub | sudo apt-key add
Create the repository configuration file:
sudo sh -c 'echo "deb https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/$(lsb_release -cs) pgadmin4 main" > /etc/apt/sources.list.d/pgadmin4.list && apt update'
Install pgAdmin
Install for both desktop and web modes:
sudo apt install pgadmin4
Install for desktop mode only:
sudo apt install pgadmin4-desktop
Install for web mode only:
sudo apt install pgadmin4-web
Configure the webserver, if you installed pgadmin4-web:
sudo /usr/pgadmin4/bin/setup-web.sh
As printed in log issue is in
File "/usr/lib/python3/dist-packages/paramiko/sftp_file.py", line 66
self._close(async=True)
The problem seems to be with the name choosen for the variable async set to True in the above example.
async is also a python command, so I suppose Python interpret async as the python command not a variable.
I renamed all async variable to aasync in file "/usr/lib/python3/dist-packages/paramiko/sftp_file.py" and then try to install python3-paramiko.
I have no error anymore.

how to fix environment error in open-ai gym?

code:
import gym
env = gym.make('Breakout-v0')
I get an error:
Traceback (most recent call last):
File "C:/Users/danie/Downloads/Programming/Python/Programming/Pycharm/app.py", line 40, in
gym.make("Breakout-v0")
File "C:\Users\danie\AppData\Local\Programs\Python\Python37\lib\site-packages\gym\envs\registration.py", line 156, in make
return registry.make(id, **kwargs)
File "C:\Users\danie\AppData\Local\Programs\Python\Python37\lib\site-packages\gym\envs\registration.py", line 101, in make
env = spec.make(**kwargs)
File "C:\Users\danie\AppData\Local\Programs\Python\Python37\lib\site-packages\gym\envs\registration.py", line 72, in make
cls = load(self.entry_point)
File "C:\Users\danie\AppData\Local\Programs\Python\Python37\lib\site-packages\gym\envs\registration.py", line 17, in load
mod = importlib.import_module(mod_name)
File "C:\Users\danie\AppData\Local\Programs\Python\Python37\lib\importlib_init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1006, in _gcd_import
File "", line 983, in _find_and_load
File "", line 967, in find_and_load_unlocked
File "", line 677, in load_unlocked
File "", line 728, in exec_module
File "", line 219, in call_with_frames_removed
File "C:\Users\danie\AppData\Local\Programs\Python\Python37\lib\site-packages\gym\envs\atari_init.py", line 1, in
from gym.envs.atari.atari_env import AtariEnv
File "C:\Users\danie\AppData\Local\Programs\Python\Python37\lib\site-packages\gym\envs\atari\atari_env.py", line 9, in
import atari_py
File "C:\Users\danie\AppData\Local\Programs\Python\Python37\lib\site-packages\atari_py_init.py", line 1, in
from .ale_python_interface import *
File "C:\Users\danie\AppData\Local\Programs\Python\Python37\lib\site-packages\atari_py\ale_python_interface.py", line 18, in
'ale_interface/build/ale_c.dll'))
File "C:\Users\danie\AppData\Local\Programs\Python\Python37\lib\ctypes_init.py", line 434, in LoadLibrary
return self.dlltype(name)
File "C:\Users\danie\AppData\Local\Programs\Python\Python37\lib\ctypes_init.py", line 356, in init
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found
I was finally able to get around this problem with help from the following website: https://towardsdatascience.com/how-to-install-openai-gym-in-a-windows-environment-338969e24d30.
There were basically 3 things I had to do: 1) install Microsoft Visual C++ Build Tools, 2) install this specific verion of Atari https://github.com/Kojoley/atari-py.git, 3) Install Xming. Good luck to all Windows users :) This took me around 3 days to figure out.
I have tried to make it work with python 3.8 and 3.9 on Windows 10. Installing Python 3.7 and using it as the Python Interpreter on PyCharm resolved the issue. I have searched for the missing file while having 3.8 + version of Python and it did not exist at all. Atari-py is supported only for Python 3.7 (https://github.com/openai/atari-py) so having a higher version of that would not work. It is a bad idea to download files from unlicensed places so I advise you to install the supported version of Python (3.5, 3.6, and 3.7). Even though gym can work on 3.9 the atari version will not. I did not need anything else installed (although I may have Microsoft Visual C++ Build Tools, but I deff did not need Xming), just import gym 0.18.0, pyglet 1.5.0, atari -py 0.2.6
Welcome to SO. If you trace the exception trace you see that a shared object loading function is called in ctypes' init.py file aliased as dlopen. On Windows, this correponds to WINAPI's LoadLibrary method. LoadLibrary is trying to load ale_c.dll. ALE is 'arcade learning environment'.
Search your computer for ale_c.dll or libale_c.dll
If you have ale_c.dll (most likely you are on Windows), refer to this answer to see how DLL's loaded with ctypes are basically LoadLibrary calls as I mentioned. It mentions all the stuff about DLL loading order etc. but, if you need a quick way around this, copy your dll under system32 folder.
I had similar issue with Atari-Pacman. It is resolved by downloading atari_py-1.2.1-cp37-cp37m-win_amd64 which is for 64-bit Python 3.7, and installing it by using pip.

venv doesn't appear to be getting used by Python

I have Python installed on the Mac. If I run python -V it outputs 3.7.2
If I run the following:
virtualenv venv
source venv/bin/activate
python -V
I see 3.7.2.
If I try to run nose I get this error:
$ nosetests -s -v config_test.test_config:TestConfiguration
Failure: ModuleNotFoundError (No module named 'boto3') ... ERROR
======================================================================
ERROR: Failure: ModuleNotFoundError (No module named 'boto3')
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/nose/failure.py", line 39, in runTest
raise self.exc_val.with_traceback(self.tb)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/nose/loader.py", line 418, in loadTestsFromName
addr.filename, addr.module)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/nose/importer.py", line 47, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/nose/importer.py", line 94, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/imp.py", line 234, in load_module
return load_source(name, filename, file)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/imp.py", line 172, in load_source
module = _load(spec)
File "<frozen importlib._bootstrap>", line 675, in _load
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
File "/Users/me/git/sdk-python-config/config_test/config_sdk.py", line 4, in <module>
import boto3
ModuleNotFoundError: No module named 'boto3'
----------------------------------------------------------------------
Ran 1 test in 0.001s
FAILED (errors=1)
I'm immediately concerned with the 3.6 references.
If I then run pip install boto3 I can see the package when I run pip list however I get the same error as above when I try running my applicaiton again.
I've tried pyenv global 3.7.2 and pyenv local 3.7.2 but neither makes any difference.
Can anybody suggest what the problem might be?
nose wasn't installed in the venv. After I installed it with pip install nose I had to deactivate the venv and reactivate it.

Converting py file to exe, Cannot find existing PyQt5 plugin directories

I'm quite new to phyton and I've just finished my first application.
Now, I'm trying to compile my .py file to an .exe buy that doestn seem to work.
I've looked everywhere for a solutio to my problem, but I just cant seem to find one.
When I run this command: pyinstaller gui.py
this error shows up:
4815 INFO: Loading module hooks...
4815 INFO: Loading module hook "hook-encodings.py"...
4913 INFO: Loading module hook "hook-pydoc.py"...
4913 INFO: Loading module hook "hook-PyQt5.py"...
5019 WARNING: Hidden import "PyQt5.sip" not found!
5019 INFO: Loading module hook "hook-PyQt5.QtCore.py"...
5096 WARNING: Unable to find Qt5 translations C:/qt5b/qt_1524647842210/_h_env/Library/translations\qtbase_*.qm. These translations were not packaged.
5096 INFO: Loading module hook "hook-PyQt5.QtGui.py"...
Traceback (most recent call last):
File "c:\users\ivo\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\users\ivo\anaconda3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\Ivo\Anaconda3\Scripts\pyinstaller.exe\__main__.py", line 9, in <module>
File "c:\users\ivo\anaconda3\lib\site-packages\PyInstaller\__main__.py", line 111, in run
run_build(pyi_config, spec_file, **vars(args))
File "c:\users\ivo\anaconda3\lib\site-packages\PyInstaller\__main__.py", line 63, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "c:\users\ivo\anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 838, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "c:\users\ivo\anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 784, in build
exec(text, spec_namespace)
File "<string>", line 17, in <module>
File "c:\users\ivo\anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 241, in __init__
self.__postinit__()
File "c:\users\ivo\anaconda3\lib\site-packages\PyInstaller\building\datastruct.py", line 158, in __postinit__
self.assemble()
File "c:\users\ivo\anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 500, in assemble
module_hook.post_graph()
File "c:\users\ivo\anaconda3\lib\site-packages\PyInstaller\building\imphook.py", line 410, in post_graph
self._load_hook_module()
File "c:\users\ivo\anaconda3\lib\site-packages\PyInstaller\building\imphook.py", line 377, in _load_hook_module
self.hook_module_name, self.hook_filename)
File "c:\users\ivo\anaconda3\lib\site-packages\PyInstaller\compat.py", line 736, in importlib_load_source
return mod_loader.load_module()
File "<frozen importlib._bootstrap_external>", line 399, in _check_name_wrapper
File "<frozen importlib._bootstrap_external>", line 823, in load_module
File "<frozen importlib._bootstrap_external>", line 682, in load_module
File "<frozen importlib._bootstrap>", line 265, in _load_module_shim
File "<frozen importlib._bootstrap>", line 684, in _load
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "c:\users\ivo\anaconda3\lib\site-packages\PyInstaller\hooks\hook-PyQt5.QtGui.py", line 11, in <module>
hiddenimports, binaries, datas = add_qt5_dependencies(__file__)
File "c:\users\ivo\anaconda3\lib\site-packages\PyInstaller\utils\hooks\qt.py", line 514, in add_qt5_dependencies
more_binaries = qt_plugins_binaries(plugin, namespace=namespace)
File "c:\users\ivo\anaconda3\lib\site-packages\PyInstaller\utils\hooks\qt.py", line 132, in qt_plugins_binaries
pdir = qt_plugins_dir(namespace=namespace)
File "c:\users\ivo\anaconda3\lib\site-packages\PyInstaller\utils\hooks\qt.py", line 117, in qt_plugins_dir
""".format(namespace, ", ".join(paths)))
Exception:
Cannot find existing PyQt5 plugin directories
Paths checked: C:/qt5b/qt_1524647842210/_h_env/Library/plugins
My path variable:
C:\Users\Ivo\Anaconda3;C:\Users\Ivo\Anaconda3\Library\mingw-w64\bin;C:\Users\Ivo\Anaconda3\Library\usr\bin;C:\Users\Ivo\Anaconda3\Library\bin;C:\Users\Ivo\Anaconda3\Scripts;C:\Users\Ivo\AppData\Local\Programs\Python\Python36-32\Scripts\;C:\Users\Ivo\AppData\Local\Programs\Python\Python36-32\;C:\Users\Ivo\AppData\Local\Microsoft\WindowsApps;C:\Users\Ivo\AppData\Roaming\Composer\vendor\bin;C:\Users\Ivo\AppData\Local\atom\bin;C:\scrcpy-windows-v1.0\adb.exe;D:\xampp2\php;C:\Users\Ivo\AppData\Roaming\npm;
Ive been trying to fix this for a whole day now, if anyone could help me/ point me in the right direction that would be greatly appericiated.
edit:
Also, since i've reinstalled some things to try and fix the problem. the file wont start and gives this error:
Traceback (most recent call last):
File "C:\Users\Ivo\Documents\temp\project\gui.py", line 9, in <module>
from PyQt5 import QtCore, QtGui, QtWidgets
ImportError: DLL load failed: The specified procedure could not be found.
Conda 4.5.11,
Python 3.6.4,
PyInstaller 3.4
The plugin path is determined incorrectly in hooks/qt.py. Qt requires that QCoreApplication is instantiated first, before any other calls.
My qt.py hook is in ~\anaconda3\Lib\site-packages\PyInstaller\utils\hooks\qt.py.
I edited it like so:
json_str = exec_statement("""
import sys
# exec_statement only captures stdout. If there are
# errors, capture them to stdout so they can be displayed to the
# user. Do this early, in case PyQt5 imports produce stderr
# output.
sys.stderr = sys.stdout
import json
from %s.QtCore import QLibraryInfo, QCoreApplication
# QLibraryInfo isn't always valid until a QCoreApplication is
# instantiated.
app = QCoreApplication([])
paths = [x for x in dir(QLibraryInfo) if x.endswith('Path')]
location = {x: QLibraryInfo.location(getattr(QLibraryInfo, x))
for x in paths}
try:
version = QLibraryInfo.version().segments()
except AttributeError:
version = None
print(str(json.dumps({
'isDebugBuild': QLibraryInfo.isDebugBuild(),
'version': version,
'location': location,
})))
""" % self.namespace)
see 1.
Try the fix in Exception: Cannot find PyQt5 plugin directories when using Pyinstaller despite PyQt5 not even being used. In short:
pip intall PyQt5
Note that, strangely enough, conda install PyQt5 may not fix the problem.
I encountered the same problem and saw another suggestion: make the missing directory (C:/qt5b/qt_1524647842210/_h_env/Library/plugins in your case) and copy the two files pyqt5.dll and pyqt5qmlplugin.dll (presumably somewhere in c:\Users[name]\AppData\Local\conda\conda\envs) to the directory.
I did not try it since I fixed the problem with pip install PyQt5. You may want to give it a try.
I am using Python 3.6.3 with ANACONDA3 and Spyder as IDE. Pyinstaller 3.4.
Trying to generate an exe file with Pyinstaller, I had two kinds of errors:
"AttributeError: 'str' object has no attribute 'items' ". This was resolved by
updating each module imported in the Python script, with :
pip install --upgrade <module_name>
"Cannot find existing PyQt5 plugin directories" :this was the next error. As
mentioned by cong yu in his previous post, I fixed this problem by running
pip install PyQt5
Do not forget to upgrade setuptools to the latest version as well
The process delivered an exe file which I have not yet tested.
But at least, I got Pyinstaller reaching the end without failing in error.
Hope this could be helpful
And, by the way, Happy New Year :)
Edit:
I have tested the standalone .exe produced by py2exe
The program is running and get to the end without errors.
But the problem is that xlsx is no more running, because no Excel
files are created. These files are based on pandas dataframes.
My hint is that pandas module, which is the main core of the program,
seems to be altered. I noticed that the dataframes used were truncated,
through the control lines edited in the Ipython console in Spyder.
I think that my best alternative is to reinstall Anaconda3.
So be careful, upgrading the modules used in the program you want as
standalone with py2exe. It seems that upgrading pandas module was a
mistake.
I am sorry, if I gave a bad advice in my main post, but upgrading was the
best way to run py2exe. Be careful with the upgrade of pandas.
Try uninstalling Anaconda. There have been issues in the past. If not you can try py2exe that is fairly decent too.
I installed the latest version of PyInstaller, then this exception of "Cannot find existing PyQt5 plugin directories" is addressed.
You can install the latest version of PyInstaller through the following command:
pip install https://github.com/pyinstaller/pyinstaller/tarball/develop
P.S: Some information about my setup:
$conda info
conda version : 4.6.14
conda-build version : 3.17.8
python version : 3.7.3.final.0
platform : win-64
user-agent : conda/4.6.14 requests/2.21.0 CPython/3.7.3 Windows/10 Windows/10.0.17763
$ pip show pyinstaller
Name: PyInstaller
Version: 3.5.dev0+d74052489
Summary: PyInstaller bundles a Python application and all its dependencies into a single package.

VirtualEnv and Scrapy

I'll try to explain this, hopefully it makes sense.
I had installed a virtual env a while ago in the directory: desktop/project_website/test_project/env and activate it to do some websites.
I also pip installed scrapy on the desktop/project_website/test_project/env/Scripts dir
The problem is that whenever I use the command prompt to run scrapy I need to be in this specific directory, so all the files that scrapy creates are made in there, not in the directory where my project is (that is desktop/project_website/Scrapy)
I already tried setting the path of where scrapy was installed into my project directory:
(Test_Project) C:\Users\A\Desktop\Project_Website\Scrapy>path
PATH=%path%;C:\Users\A\Desktop\Project_Website\Test_Project\env\Scripts
And getting this error:
(Test_Project) C:\Users\A\Desktop\Project_Website\Scrapy>scrapy
Traceback (most recent call last):
File "C:\Python\Python35\Lib\runpy.py", line 184, in _run_module_as_main
"__main__", mod_spec)
File "C:\Python\Python35\Lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\A\Desktop\Project_Website\Test_Project\env\Scripts\scrapy.exe\__main__.py", line 9, in <module>
File "c:\users\a\desktop\project_website\test_project\env\lib\site-packages\scrapy\cmdline.py", line 108, in execute
settings = get_project_settings()
File "c:\users\a\desktop\project_website\test_project\env\lib\site-packages\scrapy\utils\project.py", line 68, in get_project_settings
settings.setmodule(settings_module_path, priority='project')
File "c:\users\a\desktop\project_website\test_project\env\lib\site-packages\scrapy\settings\__init__.py", line 292, in setmodule
module = import_module(module)
File "c:\users\a\desktop\project_website\test_project\env\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ImportError: No module named 'quotes.settings'; 'quotes' is not a package
So, in short anyone know what can I do to run scrapy in my project dir? Thanks.
UPDATE - SOLVED:
Instead of using the to virtual env pathC:\Users\A\Desktop\Project_Website\Test_Project\env\Scripts I set it to where I installed scrapy on my PC c:\python\python35\scripts and it's working now.
By default, the python interpreter that occurs first in the paths will be used. You can specifically mention which interpreter to use. Something like this:
$ path_to_dir\env\bin\python runpy.py

Categories