TypeError: catch_config_error() takes exactly 2 arguments (1 given)
I am installing ipython in an virtual environment. After installation i am unable to start it using terminal.it is showing following error
from IPython import start_ipython File "/Users/sandeepkumarsharma/envipyhton/lib/python2.7/site-packages/IPython/__init__.py", line 48, in <module> from .core.application import Application File "/Users/sandeepkumarsharma/envipyhton/lib/python2.7/site-packages/IPython/core/application.py", line 23, in <module> from traitlets.config.application import Application, catch_config_error File "/Users/sandeepkumarsharma/envipyhton/lib/python2.7/site-packages/traitlets/config/__init__.py", line 6, in <module> from .application import * File "/Users/sandeepkumarsharma/envipyhton/lib/python2.7/site-packages/traitlets/config/application.py", line 120, in <module> class Application(SingletonConfigurable): File "/Users/sandeepkumarsharma/envipyhton/lib/python2.7/site-packages/traitlets/config/application.py", line 291, in Application def initialize(self, argv=None): TypeError: catch_config_error() takes exactly 2 arguments (1 given)
See also questions close to this topic
How to pass None keyword as command line argument
I am trying to pass
Nonekeyword as a command line parameter to a script as follows, if I explicity mention
Category=Noneit works but the moment I switch to
sys.argvit fails, any pointers on how to fix this?
category = None --> works #category=sys.argv --> doesn't work
so I tried as below which still didn't work
if sys.argv.strip()==None: category = None else: category=sys.argv.strip()
Command line passage:
Cross correlation for two audio clips using python
I want to calculate Cross Correlation between two voice clip y and y1, to find the either both voice clips are same or not. For this i am using these code but it gives me the wrong output. It gives me the Cross correlation value is 49.4882, which is wrong. Here is my code:
from scipy.stats.stats import pearsonr import numpy as np import librosa y,sr = librosa.load('C:/Users/R Studio/Desktop/1201/data/cant.wav') y1,sr1 = librosa.load('C:/Users/R Studio/Desktop/1201/data/smells.wav') a = np.correlate(y,y1) print(a) b = (np.linalg.norm(a)) print(b)
Anybody can help me to correct this code? So that i cant get the correct correlation.
Thanks in advanced
Bokeh inside Google Colab
Matplotlib doesn't give me the visualisation I want
I like the interactive features of Bokeh and I would like to see if someone was able to get it running inside Google Colab?
I installed the library (from the notebook itself) and it showed the installation is successful
!pip install bokeh
Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing
How do I connect to an FT230 with pylibftdi?
I have exactly one FTDI FT230X connected to my machine. I can see the device using
$ lsusb Bus 002 Device 005: ID 051d:0002 American Power Conversion Uninterruptible Power Supply Bus 002 Device 004: ID 046d:c408 Logitech, Inc. Marble Mouse (4-button) ... Bus 003 Device 010: ID 0403:6015 Future Technology Devices International, Ltd Bridge(I2C/SPI/UART/FIFO) ...
0403:6015entry is the FT230X. I'd like to talk to this thing in Python, so we do
>>> import pylibftdi >>> dev = pylibftdi.Device()
but get an error message reading
~/.virtualenvs/labrad/local/lib/python2.7/site-packages/pylibftdi/device.pyc in __init__(self, device_id, mode, encoding, lazy_open, chunk_size, interface_select, device_index, auto_detach, **kwargs) 114 # lazy_open tells us not to open immediately. 115 if not lazy_open: --> 116 self.open() 117 118 def __del__(self): ~/.virtualenvs/labrad/local/lib/python2.7/site-packages/pylibftdi/device.pyc in open(self) 154 self.fdll.ftdi_deinit(byref(self.ctx)) 155 del self.ctx --> 156 raise FtdiError(msg) 157 158 if self.auto_detach and self.driver.libftdi_version().major > 0: FtdiError: device not found (-3)
We can also try specifying the serial number explicitly:
>>> import usb.core >>> devs = list(usb.core.find(find_all=True)) >>> for x in str(devs).split(','): print(x) [<DEVICE ID 051d:0002 on Bus 002 Address 005> <DEVICE ID 046d:c408 on Bus 002 Address 004> <DEVICE ID 04ca:006e on Bus 002 Address 003> <DEVICE ID 8087:0024 on Bus 002 Address 002> <DEVICE ID 1d6b:0002 on Bus 002 Address 001> <DEVICE ID 1d6b:0003 on Bus 004 Address 001> <DEVICE ID 1366:0101 on Bus 003 Address 009> <DEVICE ID 0403:6015 on Bus 003 Address 010> # <-- that one <DEVICE ID 1d6b:0002 on Bus 003 Address 001> <DEVICE ID 1050:0211 on Bus 001 Address 003> <DEVICE ID 8087:0024 on Bus 001 Address 002> <DEVICE ID 1d6b:0002 on Bus 001 Address 001>] >>> my_dev = devs >>> ser = devs.serial_number >>> import pylibftdi >>> pylibftdi.Device(ser)
Why is this happening? The pylibftdi documentation claims that the
Deviceconstructor should take the first available device, and there's only one in my case. The error message saying "device not found" makes me wonder whether the FT230X is supported by the driver that pylibftdi is using, which I believe to be
libftdi1in my case.
How to simplify the loops and make it work?
I have one array of distances (lshell4_int) and values, recorded by 6 channels (electrons4). They are in quite chaotic order, and what I have to do is the following. I know that the distances take values from 1 to 9 and I have an array of distances with spacing 0.2 (lshell). I need to sort my big array of values by the distances, summarize all the values that have corresponding values in every 0.2 'cell', divide them by the number of values in every cell. That I have to do for all 6 channels in electrons4. Then I have to plot a map or something like that with lshell on X-axis, Echannel on Y-axis and the new variable that we get in the loops as the field value. I thought of representation using pcolor... This is my code:
lshell=numpy.linspace(1,9,45) print(lshell) Echannel=numpy.arange(1,7) print(Echannel) electrons4_bin=numpy.zeros([len(lshell), 6]) ind4=numpy.zeros([len(lshell), 6]) for i in range(len(lshell)-1): for j in range(len(lshell4_int)): if lshell4_int[j]>=lshell[i] and lshell4_int[j]<lshell[i+1]: for y in range (5): electrons4_bin[y,i]=electrons4_bin[y,i]+electrons4[j,y] ###### ind4[y,i]=ind4[y,i]+1 electrons_bin=numpy.zeros([len(lshell), 6]) electrons_bin=electrons4_bin/ind4 fig = matplotlib.pyplot.figure() ax = fig.gca() matplotlib.pyplot.pcolor(lshell,Echannel,electrons_bin, cmap='RdBu') matplotlib.pyplot.colorbar()
However, it does not work... It says that in line where I put ##### it says index 6 is out of bounds for axis 1 with size 6... How can I make it work? And what might be the optimal solution for this task? Maybe there is a solution without so many loops and if statements?
Is there a way to use ibm_db on python 2.7 64-bit on windows?
I installed python 2.7 32-bit version and I am able to run
pip install ibm_db(current version is 2.0.8), and then call
import ibm_dband everything works. When I use python 2.7 64-bit, however, the install via pip works fine, but when I try and
import ibm_dbI get the following error:
Python 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:25:58) [MSC v.1500 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import ibm_db Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Python27\lib\site-packages\ibm_db.py", line 10, in <module> __bootstrap__() File "C:\Python27\lib\site-packages\ibm_db.py", line 9, in __bootstrap__ imp.load_dynamic(__name__,__file__) ImportError: DLL load failed: %1 is not a valid Win32 application. >>>
The DLL in question is
<site-packages>/ibm_db_dlls/ibm_db.dll, and its there, but when I open it using Dependency Walker, it seems to be the 32 bit version.
Anybody know if there is a 64 bit compatible ibm_db.dll, or a way to make this work? I need this to run in an environment (windows server) with 64 bit python, and I don't have control over the version.
Fabric: executing makemigrations & migrate raises Secret Key Error
I'm working on a fabfile.py to stop repetition and deploy automatically.
I'm using the
prefix("workon vpenv"):provided by fabric but here is the problem: when running git pull everything works well, but when I run
run("python manage.py makemigrations --settings=config.settings.production")I get the following error:
[venuepark.com] run: python manage.py makemigrations --settings=config.settings.production [venuepark.com] out: Traceback (most recent call last): [venuepark.com] out: File "manage.py", line 22, in <module> [venuepark.com] out: execute_from_command_line(sys.argv) [venuepark.com] out: File "/home/tony/.virtualenvs/vpenv/lib/python3.6/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line [venuepark.com] out: utility.execute() [venuepark.com] out: File "/home/tony/.virtualenvs/vpenv/lib/python3.6/site-packages/django/core/management/__init__.py", line 307, in execute [venuepark.com] out: settings.INSTALLED_APPS [venuepark.com] out: File "/home/tony/.virtualenvs/vpenv/lib/python3.6/site-packages/django/conf/__init__.py", line 56, in __getattr__ [venuepark.com] out: self._setup(name) [venuepark.com] out: File "/home/tony/.virtualenvs/vpenv/lib/python3.6/site-packages/django/conf/__init__.py", line 41, in _setup [venuepark.com] out: self._wrapped = Settings(settings_module) [venuepark.com] out: File "/home/tony/.virtualenvs/vpenv/lib/python3.6/site-packages/django/conf/__init__.py", line 110, in __init__ [venuepark.com] out: mod = importlib.import_module(self.SETTINGS_MODULE) [venuepark.com] out: File "/home/tony/.virtualenvs/vpenv/lib/python3.6/importlib/__init__.py", line 126, in import_module [venuepark.com] out: return _bootstrap._gcd_import(name[level:], package, level) [venuepark.com] out: File "<frozen importlib._bootstrap>", line 994, in _gcd_import [venuepark.com] out: File "<frozen importlib._bootstrap>", line 971, in _find_and_load [venuepark.com] out: File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked [venuepark.com] out: File "<frozen importlib._bootstrap>", line 665, in _load_unlocked [venuepark.com] out: File "<frozen importlib._bootstrap_external>", line 678, in exec_module [venuepark.com] out: File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed [venuepark.com] out: File "/home/tony/vp/vp/config/settings/production.py", line 1, in <module> [venuepark.com] out: from .base import * [venuepark.com] out: File "/home/tony/vp/vp/config/settings/base.py", line 24, in <module> [venuepark.com] out: SECRET_KEY = os.environ["VP_SECRET_KEY"] [venuepark.com] out: File "/home/tony/.virtualenvs/vpenv/lib/python3.6/os.py", line 669, in __getitem__ [venuepark.com] out: raise KeyError(key) from None [venuepark.com] out: KeyError: 'VP_SECRET_KEY' [venuepark.com] out: Fatal error: run() received nonzero return code 1 while executing! Requested: python manage.py makemigrations --settings=config.settings.production Executed: /bin/bash -l -c "cd /home/tony/vp/vp >/dev/null && workon vpenv && python manage.py makemigrations --settings=config.settings.production"
my fabfile.py is as follows:
def deploy(): code_directory = "/path/to/somewhere" with cd(code_directory): with prefix("workon vpenv"): run("git pull") run("python manage.py makemigrations --settings=config.settings.production") run("python manage.py migrate --settings=config.settings.production") run("python manage.py collectstatic --settings=config.settings.production") sudo("pkill gunicorn") sudo("systemctl daemon-reload") sudo("systemctl start gunicorn") sudo("systemctl enable gunicorn") sudo("systemctl restart nginx")
What could cause the error?
When I run the commands on the server itself I get no errors.
How to access Python script outside of virtualenv
My situation: I'm running PyCharm for a new project where I use two scripts:
- one (
main.py) that runs continuously
- a second one (
sub.py, located in the same root directory) that will be called using
main.pywhenever a certain requirement is met
However, it seems that the virtualenv that PyCharm creates and activates automatically is preventing
Copying my code to a different environment without a virtualenv and running it works as intended.
Is there a way to add the second script to the same virtualenv, or call it outside the virtualenv successfully?
from flask import Flask import subprocess ext = Flask(__name__) @ext.route('/') def hello_world(): subprocess.Popen(["python", "channel.py"]) return 'Hello World!' if __name__ == '__main__': ext.run()
- one (
Why pipenv is not allowing to choose virtualenv location?
I have found a good alternative
pipenvwhich aims to replace a combo of
pipenvmakes it difficult for the user to chose
virtualenvlocation and rather stores it in the standard location:
$HOME/.local/share/virtualenvs/project_name-HaSh. The only alternative is setting
PIPENV_VENV_IN_PROJECTenv. variable, in which case
virtualenvwill be stored in the same directory as the project.
Essentially it looks like a design decision (a bad one IMHO).
So what's wrong with letting users decide where they wanna keep their environments? Why this has been standardized?