Q_Id
int64
337
49.3M
CreationDate
stringlengths
23
23
Users Score
int64
-42
1.15k
Other
int64
0
1
Python Basics and Environment
int64
0
1
System Administration and DevOps
int64
0
1
Tags
stringlengths
6
105
A_Id
int64
518
72.5M
AnswerCount
int64
1
64
is_accepted
bool
2 classes
Web Development
int64
0
1
GUI and Desktop Applications
int64
0
1
Answer
stringlengths
6
11.6k
Available Count
int64
1
31
Q_Score
int64
0
6.79k
Data Science and Machine Learning
int64
0
1
Question
stringlengths
15
29k
Title
stringlengths
11
150
Score
float64
-1
1.2
Database and SQL
int64
0
1
Networking and APIs
int64
0
1
ViewCount
int64
8
6.81M
32,715,175
2015-09-22T11:02:00.000
1
0
0
0
python,mysql,django
32,723,517
3
false
1
0
This approach worked ! I was able to install the mysqlclient inside the virtual environment through the following command:- python -m pip install mysqlclient Thanks Much..!!!!!
1
0
0
I had posted about this error some time back but need some more clarification on this. I'm currently building out a Django Web Application using Visual Studio 2013 on a Windows 10 machine (Running Python3.4). While starting out I was constantly dealing with the MySQL connectivity issue, for which I did a mysqlclient pip-install. I had created two projects that use MySQL as a backend and after installing the mysqlclient I was able to connect to the database through the current project I was working on. When I opened the second project and tried to connect to the database, I got the same 'No Module called MySqlDB' error. Now, the difference between both projects was that the first one was NOT created within a Virtual Environment whereas the second was. So I have come to deduce that projects created within the Python virtual environment are not able to connect to the database. Can someone here please help me in getting this problem solved. I need to know how the mysqlclient module can be loaded onto a virtual environment so that a project can use it. Thanks
No Module Named MySqlDb in Python Virtual Enviroment
0.066568
1
0
660
32,719,789
2015-09-22T14:36:00.000
2
0
0
0
python,tkinter
32,720,291
1
true
0
1
No, there is no supported way to get the command via introspection. Your solution of adding it as an attribute is a perfectly reasonable thing to do. If you're bothered by the fact it takes two lines of code instead of one, you can subclass the button to hide that detail.
1
1
0
After a ttk.Button has been created, the name of the callback function can be obtained in various ways. But is there a way to obtain the callback function itself? The use case is that I want to use the button's callback function in the callback function to be assigned to another widget. Currently I'm assigning the button's callback function to an additional attribute of the Button object after creating it. That's redundant, though, and I'd like to get the callback function directly from the Button object itself, if possible.
How can the command function be obtained from a Tkinter button?
1.2
0
0
34
32,724,891
2015-09-22T19:04:00.000
1
0
1
0
python,python-3.x
32,725,931
1
true
0
0
Let's say you have a program that reads a temperature from a sensor every minute, and stores them in a list. You might end up with a list like this: [23, 24, 24, 23, 25, 24] Now let's assume that sometimes the connection to your sensor fails (maybe it's wireless), and you get no reading. What do you put in your list? If you leave it out, you won't have an even 1-minute spacing between values any more. If you store a 'special' number (e.g. 0 or -1 or something) you'll have to know that the particular 'special' value means 'no measurement'. Using the None value for that is pretty handy, because it makes it clear that there is no value there. E.g. something like this: [23, 24, None, 23, None, 24]
1
0
0
I'm reading an online book about Python,and the writer mentioned that "the None value can be helpful when you need to store something that won’t be confused for a real value in a variable", but I didn't understand it.Can anybody explain that for me with an example?
The None value in Python
1.2
0
0
196
32,725,493
2015-09-22T19:42:00.000
1
0
0
0
python-3.x,flask
32,732,460
1
true
1
0
Short answer: Depends on when and where the class is initialised. Objects have little to do with a user logging in and logging out. Object lifetimes are dependent on when and where they are initialised. Objects initialised outside a function or class are effectively singletons and last as long as the application instance exists Objects initialised inside a class last as long as the orginal object last. Objects initialised inside a function exist until the function completes execution. Now classes that handle database requests are better kept as singletons. This avoids the necessity of creating new database connections every time a query has to be executed. So the easiest way to create a singleton would be to declare it as a variable in a module outside a function or class
1
1
0
I have a web app that retrieves data from a database and displays it on a UI. I have a class called table that handles the database requests based on the URL variables. My question is: Does flask recycle objects when a new URL is requested? Or does it keep the objects in memory until the user logs out? Should I have one table object and just update the query every time the URL changes? Or should I just create a new object?
Lifetime of objects in a flask app
1.2
0
0
958
32,728,024
2015-09-22T22:27:00.000
0
0
1
0
python,bit,valueconverter
32,728,304
3
false
0
0
maybe someone will need: From ctypes import c_short C_short (0xF800 | (N & 0x7ff)). Value
1
1
0
I have the formula: (short) (0xF800 | (N & 0x7ff)). With the help of C/CPP/C# I changed the sign of the eight-bit numbers (eg 1202 numbers to -846). In Python this trick is not working. How do I get the same result?
operation with bit in python
0
0
0
123
32,739,428
2015-09-23T12:19:00.000
2
0
0
0
python,modelica
32,745,918
2
false
1
0
It might be a strcutrual parameter, these are evaluated also. It should work if you explicitly set Evaluate=False for the parameter that you want to study. Is it not visible in the variable browser or is it just greyed out and constant? If it is not visible at all you should check if it is protected.
1
3
0
I want to run parameter studies in different modelica building libraries (buildings, IDEAS) with python: For example: change the infiltration rate. I tried: simulateModel and simulateExtendedModel(..."zone.n50", [value]) My questions:Why is it not possible to translate the model and then change the parameter: Warning: Setting zone.n50 has no effect in model. After translation you can only set literal start-values and non-evaluated parameters. It is also not possible to run: simulateExtendedModel. When i go to command line in dymola and write for zone.n50, then i get the actual value (that i have defined in python), but in the result file (and the plotted variable) it is always the standard n50 value.So my question: How can I change values ( befor running (and translating?) the simulation? The value for the parameter is also not visible in the variable browser. Kind regards
Modelica Parameter studies with python
0.197375
0
0
738
32,742,093
2015-09-23T14:18:00.000
20
0
0
1
python,windows,python-2.7,cmd
32,742,619
2
true
0
0
py command comes with Python3.x and allow to choose among multiple Python interpreters. For example if you have both Python 3.4 and 2.7 installed, py -2 will start python2.7 and py -3 will start python3.4 . If you just use py it will start the one that was defined as default. So the official way would be to install Python 3.x, declare Python 2.7 as the default, and the py command will do its job. But if you just want py to be an alias of python, doskey py=python.exe as proposed by @Nizil and @ergonaut will be much simpler... Or copying python.exe to py.exe in Python27 folder if you do not want to be bothered by the limitations of doskey.
1
6
0
I have a very weird request. An executable I have has a system call to a python script which goes like py file1.py Now, in my system though py is shown as an unrecognized internal or external command. python file1.py works however. is there some way I can get my windows command prompt to recognize that py and python refer to the same thing?
how to access python from command line using py instead of python
1.2
0
0
29,688
32,743,668
2015-09-23T15:28:00.000
1
0
0
0
python,django,authentication,django-rest-framework,one-time-password
32,759,648
1
true
1
0
You can create a view that generates a time-based OTP and then use it in a custom auth module to authenticate against a single user. You can also use JWT with an expiry time to authenticate against a single user.
1
2
0
I have a Django and django rest framework project where I want a mobile to be able to request a token and then use that token for x minutes before they're disconnected. I do not want to create a user for each mobile device, I just want a one time password. I tried using the auth system built into drf, however it required a user. So I was thinking about just using the onetimepass package to generate a one time token.
Python Django DRF API one time session/token/pass authentication without a username/password
1.2
0
0
1,261
32,751,538
2015-09-24T00:29:00.000
0
0
0
0
android,python,rotation,kivy,buildozer
32,758,159
2
true
0
1
It would be much better to just not use absolute coordinates, but rather to use kivy's layout classes to achieve relative positioning (you can also specify the relative positioning manually but that's harder and more verbose, and you're just reinventing the layouts if you do it). In any case, the direct answer to your question is that there may be an android api function you can call to get the orientation if you really want, or in reality you presumably care specifically about the window size which is exposed by kivy.core.window.Window.size
1
0
0
I just made an apk app using kivy. In the code, I defined the positions of all widgets according to scale of the screen. However, when I rotate the screen, say, from portrait to landscape, the absolute coordinates still stay the same, and it doesn't fit in very well. Is there a method to identify whether portrait or landscape is being displayed? I need this in order to re-define the positions of my widget when user rotates the phone.
How to identify whether the screen is in Portrait or Landscape in Kivy
1.2
0
0
888
32,755,412
2015-09-24T07:09:00.000
0
1
1
0
python,function,python-import,code-organization
32,755,617
3
true
0
0
It's a common use to make all imports on top, mainly for readability: you shouldn't have to look around the whole code to find an import. Of course you have to import a symbol before you can use it. Anyway in Python it's not always wrong to import inside functions or classes, this is because of the way Python actually interpret the import. When you import a module you are actually running it's code, that is, in most cases, just defining new symbols, but could be also to trigger some side effect; thus it sometimes make sense to import inside functions to make the imported code execute only on function call.
3
1
0
I'm writing a password management program that encrypts the passwords and saves the hashes to a document. Should I import before defining the functions, import in the functions they are used, or import after defining the functions but before running the functions. I'm trying to make my code as neat as possible. I'm currently importing passlib.hash, sha256_crypt, os.path, time. Sorry if it's not clear I'm kind of new and trying to teach myself. Any advice helps.
Python - Does it matter if i import modules before or after defining functions? Newb Ques
1.2
0
0
308
32,755,412
2015-09-24T07:09:00.000
0
1
1
0
python,function,python-import,code-organization
32,755,537
3
false
0
0
It's a good style to import in the very beginning of the code. So you have an overview and can avoid multiple imports.
3
1
0
I'm writing a password management program that encrypts the passwords and saves the hashes to a document. Should I import before defining the functions, import in the functions they are used, or import after defining the functions but before running the functions. I'm trying to make my code as neat as possible. I'm currently importing passlib.hash, sha256_crypt, os.path, time. Sorry if it's not clear I'm kind of new and trying to teach myself. Any advice helps.
Python - Does it matter if i import modules before or after defining functions? Newb Ques
0
0
0
308
32,755,412
2015-09-24T07:09:00.000
0
1
1
0
python,function,python-import,code-organization
32,755,514
3
false
0
0
Typically imports come first in any design pattern I have seen. Imports > large scope variables > functions.
3
1
0
I'm writing a password management program that encrypts the passwords and saves the hashes to a document. Should I import before defining the functions, import in the functions they are used, or import after defining the functions but before running the functions. I'm trying to make my code as neat as possible. I'm currently importing passlib.hash, sha256_crypt, os.path, time. Sorry if it's not clear I'm kind of new and trying to teach myself. Any advice helps.
Python - Does it matter if i import modules before or after defining functions? Newb Ques
0
0
0
308
32,756,140
2015-09-24T07:54:00.000
2
0
0
0
python,c++,opencv,cuda,nvidia
32,797,781
1
false
0
0
Upgrading from CMake 2.8 to CMake 3.2.2 seems to have solved this particular issue. [This answer has been added from information gleaned from comments in order to get the question off the unanswered list]
1
0
1
I installed OpenCV 3.0.0 but I'm having troubles any C++ or Python code using OpenCV. For testing, I went into the directory opencv-3.0.0/samples and ran cmake to build the samples. I got the following error: CMake Error at /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:108 (message): Could NOT find CUDA: Found unsuitable version "5.5", but required is exact version "7.0" (found /usr) However, I'm pretty sure that I have the CUDA 7.0 installed and I verified by getting the following output from nvcc --version on the command line: nvcc: NVIDIA (R) Cuda compiler driver Copyright (c) 2005-2015 NVIDIA Corporation Built on Mon_Feb_16_22:59:02_CST_2015 Cuda compilation tools, release 7.0, V7.0.27 Why might OpenCV think that I got the wrong version installed? Is there a workaround for this?
OpenCV can't find the right version of CUDA
0.379949
0
0
1,214
32,756,711
2015-09-24T08:25:00.000
12
0
1
0
python,flask,virtualenv
32,756,729
1
true
1
0
No, there is no requirement to use a virtualenv. No project ever would require you to use one; it is just a method of insulating a collection of Python libraries from other projects. I personally do strongly recommend you use a virtualenv, because it makes it much, much easier to swap out versions of libraries and not affect other Python projects. Without a virtualenv, you just continue with installing the dependencies, and they'll end up in your system libraries collection. Installing the Flask project with pip will pull in a few other packages, such as Werkzeug, Jinja2 and itsdangerous. These would all be installed 'globally'.
1
6
0
I just started exploring Flask. Earlier I tried to explore Django but found it a bit complicated. However, Installing Flask requires us to install virtualenv first which, As I can recall, is not required in the case of Django. In case it is not required, how to go ahead without virtualenv?
Is it necessary to use virtualenv to use Flask framework?
1.2
0
0
2,441
32,759,078
2015-09-24T10:30:00.000
1
0
0
1
python,c,file-descriptor
32,759,245
2
false
0
0
Look earlier in the strace output for when the file descriptor was returned from open() (or perhaps socket()), there you'll see the additional arguments used in the call.
1
1
0
I am trying to debug a process that hangs, the output of strace for the process id has last line : recvfrom(9, <detached ...> From this what I understand that the process is waiting on the socket. But I don't know which or what kind of socket is this. How can I discover more about this ? does the file descriptor 9 will give me more information ? How can I use this file discover to know more about what it is waiting for ? its a python process, running in linux.
How to find more information about the file descriptor?
0.099668
0
0
2,426
32,759,082
2015-09-24T10:30:00.000
2
0
0
0
python,django,api,rest,response
32,759,144
1
true
1
0
As far as I know, No you can't send Multipart http response not yet atleast. Multipart response is only valid in http requests. Why? Because no browser as I know of completely supports this. Firefox 3.5: Renders only the last part, others are ignored. IE 8: Shows all the content as if it were text/plain, including the boundaries. Chrome 3: Saves all the content in a single file, nothing is rendered. Safari 4: Saves all the content in a single file, nothing is rendered. Opera 10.10: Something weird. Starts rendering the first part as plain/text, and then clears everything. The loading progress bar hangs on 31%. (Data credits Diego Jancic)
1
2
0
I apologise if this is a daft question. I'm currently writing against a Django API (which I also maintain) and wish under certain circumstances to be able to generate multiple partial responses in the case where a single request yields a large number of objects, rather than sending the entire JSON structure as a single response. Is there a technique to do this? It needs to follow a standard such that client systems using different request libraries would be able to make use of the functionality. The issue is that the client system, at the point of asking, does not know the number of objects that will be present in the response. If this is not possible, then I will have to chain requests on the client end - for example, getting the first 20 objects & if the response suggests there will be more, requesting the next 20 etc. This approach is an OK work-around, but any subsequent requests rely on the previous response. I'd rather ask once and have some kind of multi-part response.
Can Django send multi-part responses for a single request?
1.2
0
0
1,409
32,759,106
2015-09-24T10:32:00.000
-1
0
1
1
python
32,759,202
1
false
0
0
Simply pass the full path you have now to os.path.basename to get only the filename part.
1
0
0
I'd like to find out the currently running script's file name. Usually via __file__ or __main__.__file__ or even with sys.argv[0]. But when installed as shell command with setup.py and entry_points / console_scripts, /usr/local/bin/... is returned instead of the actual file name. My next guess was the inspect module, like inspect.stack()[1].filename. Unfortunately this was inconsistent and did not work in all cases. Any suggestions please?
actual script file name when installed as shell command with setup.py
-0.197375
0
0
31
32,760,681
2015-09-24T11:55:00.000
1
0
0
0
python,django,url,tags,server-error
32,765,111
1
false
1
0
I solved the issue by adding #-*- coding: utf-8 -*- at the begenning of all my Python (*.py) files because it's an old version about python (2.6) Thank's to all :)
1
1
0
I have an issue when I put online my Django Project. If I have an {% url ... %} tag in my main html file (base.html), I see "Server Error 500". If I remove all these lines with {% url ... %}, my django website works fine and the "Server Error 500" disappears ! I have this issue only with the URL tag. For information, I have no issue when I work locally (127.0.0.1) on my computer. My hosting (Alwaysdata.com) use python 2.6 and Django 1.6.4 Could you help me please ? :)
Django - Server error 500 with URL tag
0.197375
0
0
419
32,761,556
2015-09-24T12:38:00.000
8
0
1
0
python,parallel-processing,scikit-learn,joblib
55,287,554
3
false
0
0
what is the point of using n-jobs (and joblib) if the the library uses all cores anyway? It does not, if you specify n_jobs to -1, it will use all cores. If it is set to 1 or 2, it will use one or two cores only (test done scikit-learn 0.20.3 under Linux).
2
19
1
This is not a real issue, but I'd like to understand: running sklearn from Anaconda distrib on a Win7 4 cores 8 GB system fitting a KMeans model on a 200.000 samples*200 values table. running with n-jobs = -1: (after adding the if __name__ == '__main__': line to my script) I see the script starting 4 processes with 10 threads each. Each process uses about 25% of the CPU (total: 100%). Seems to work as expected running with n-jobs = 1: stays on a single process (not a surprise), with 20 threads, and also uses 100% of the CPU. My question: what is the point of using n-jobs (and joblib) if the the library uses all cores anyway? Am I missing something? Is it a Windows-specific behaviour?
Python scikit learn n_jobs
1
0
0
46,321
32,761,556
2015-09-24T12:38:00.000
-1
0
1
0
python,parallel-processing,scikit-learn,joblib
59,874,972
3
false
0
0
You should either use n_jobs or joblib, don't use both simultaneously.
2
19
1
This is not a real issue, but I'd like to understand: running sklearn from Anaconda distrib on a Win7 4 cores 8 GB system fitting a KMeans model on a 200.000 samples*200 values table. running with n-jobs = -1: (after adding the if __name__ == '__main__': line to my script) I see the script starting 4 processes with 10 threads each. Each process uses about 25% of the CPU (total: 100%). Seems to work as expected running with n-jobs = 1: stays on a single process (not a surprise), with 20 threads, and also uses 100% of the CPU. My question: what is the point of using n-jobs (and joblib) if the the library uses all cores anyway? Am I missing something? Is it a Windows-specific behaviour?
Python scikit learn n_jobs
-0.066568
0
0
46,321
32,762,675
2015-09-24T13:29:00.000
2
1
0
1
python,salt-stack
32,769,491
1
true
0
0
Only python extensions are supported, so your best bet is to do the following: 1) Deploy your non-Python components via a file.managed / file.recurse state. 2) Ensure your custom execution module has a __virtual__() function checking for the existence of the non-Python dependencies, and returning False if they are not present. This will keep the module from being loaded and used unless the deps are present. 3) Sync your custom modules using saltutil.sync_modules. This function will also re-invoke the loader to update the available execution modules on the minion, so if you already had your custom module sync'ed and later deployed the non-Python depenencies, saltutil.sync_modules would re-load the custom modules and, provided your __virtual__() function returned either True or the desired module name, your execution module would then be available for use.
1
0
0
I am currently transforming a perl / bash tool into a salt module and I am wondering how I should sync the non-python parts of this module to my minions. I want to run salt agent-less and ideally the dependencies would by synced automatically alongside the module itself once its called via salt-ssh. But it seems that only python scripts get synced. Any thoughts for a nice and clean solution? Copying the necessary files from the salt fileserver during module execution seems somehow wrong to me..
How to sync a salt execution module with non-python dependencies
1.2
0
0
284
32,763,625
2015-09-24T14:12:00.000
1
1
1
0
python,neo4j,py2neo
32,781,464
1
true
0
0
Depending on which version of py2neo you're using, and which Cypher endpoint - legacy or transactional - this may be one of the auto-generated errors built dynamically from the server response. Newer functionality (i.e. the transaction endpoint) no longer does this and instead holds hard-coded definitions for all exceptions for just this reason. This wasn't possible for the legacy endpoint when the full list of possible exceptions was undocumented. You should however be able to catch py2neo.error.GraphError instead which is the base class from which these dynamic errors inherit. You can then study the attributes of that error for more specific checking.
1
3
0
I'm expectedly getting a CypherExecutionException. I would like to catch it but I can't seem to find the import for it. Where is it? How do I find it myself next time?
import for py2neo.error.CypherExecutionException
1.2
0
0
139
32,768,371
2015-09-24T18:25:00.000
1
0
1
0
python,pycharm,interpreter
57,447,300
4
false
0
0
I think it's better to run this command $ sudo apt-get install python3-distutils
2
4
0
When I try to run code in editor,it says that there is no available interpreters.Please,help.How can I solve the problem?
How can I add interpreter to PyCharm?
0.049958
0
0
33,226
32,768,371
2015-09-24T18:25:00.000
0
0
1
0
python,pycharm,interpreter
69,997,735
4
false
0
0
Go to File. Settings Then you receive another window. Find line which is called project name. Expand and it Click interpeter. Then click the wheel icon which is next to the interpreter. Click add button. Then it gives a new window. Then we can create a new environment or add exiting environment. Choos is yours.....
2
4
0
When I try to run code in editor,it says that there is no available interpreters.Please,help.How can I solve the problem?
How can I add interpreter to PyCharm?
0
0
0
33,226
32,771,481
2015-09-24T21:48:00.000
1
0
0
0
python,pygame,python-idle
32,771,570
1
false
0
1
If you're on windows, a quick thing could be to make a one-line batch script. start pythonw.exe <filename> The start keyword causes the shell to not wait for the program to finish. pythonw vs python prevents the python terminal from appearing. If you're on linux/mac, you could do the same with shell scripts.
1
0
0
I'm just wondering (as im starting to make a game with pygame) is there a way to 1) Run a program that only opens a GUI and not the shell and 2) Run the program without having to edit with idle (I'd like to do this so the game will look more professional. I would like to just have a desktop shortcut or something that when clicked, runs only the GUI and doesnt show my code or show the shell.
How to make the text shell not appear when running a program
0.197375
0
0
87
32,772,343
2015-09-24T23:06:00.000
0
0
0
0
python,apache,flask
32,772,507
1
false
1
0
You could use S3 to host the file with a temporary URL. Use Flask to upload the file to S3 (using boto3), but use a dynamically-generated temporary key. Example URL: http://yourbucket.s3.amazon.com/static/c258d53d-bfa4-453a-8af1-f069d278732c/sound.mp3 Then, when you tell the user where to download the file, give them that URL. You can then delete the S3 file at the end of the time period using a cron job. This way, Amazon S3 is serving the file directly, resulting in a complete bypass of your Flask server.
1
2
0
I have a Flask app that lets users download MP3 files. How can I make it so the URL for the download is only valid for a certain time period? For example, instead of letting anyone simply go to example.com/static/sound.mp3 and access the file, I want to validate each request to prevent an unnecessary amount of bandwidth. I am using an Apache server although I may consider switching to another if it's easier to implement this. Also, I don't want to use Flask to serve the file because this would cause a performance overhead by forcing Flask to directly serve the file to the user. Rather, it should use Apache to serve the file.
How to generate temporary downloads in Flask?
0
0
0
684
32,772,672
2015-09-24T23:45:00.000
1
1
0
1
python,image,file,sequence,exists
32,875,932
2
false
0
0
You should probably not loop for candidates using os.path.isfile(), but use glob.glob() or os.listdir() and check the returned lists for matching your file patterns, i.e. prefer memory operations over disk accesses.
2
0
0
I have a potentially big list of image sequences from nuke. The format of the string can be: /path/to/single_file.ext /path/to/img_seq.###[.suffix].ext /path/to/img_seq.%0id[.suffix].ext, i being an integer value, the values between [] being optional. The question is: given this string, that can represent a sequence or a still image, check if at least one image on disk corresponds to that string in the fastest way possible. There is already some code that checks if these files exist, but it's quite slow. First it checks if the folder exists, if not, returns False Then it checks if the file exists with os.path.isfile, if it does, it returns True. Then it checks if no % or # is found in the path, and if not os.path.isfile, it returns False. All this is quite fast. But then, it uses some internal library which is in performance a bit faster than pyseq to try to find an image sequence, and does a bit more operations depending if start_frame=end_frame or not. But it stills take a large amount of time to analyze if something is an image sequence, specially on some sections of the network and for big image sequences. For example, for a 2500 images sequence, the analysis takes between 1 and 3 seconds. If I take a very naive approach, and just checks if a frame exist by replacing #### by %04d, and loop over 10000 and break if found, it takes less than .02 seconds to check for os.path.isfile(f), specially if the first frame is between 1-3000. Of course I cannot guarantee what the start frame will be, and that approach is not perfect, but in practice many of the sequences do begin between 1-3000, and I could return True if found and fallback to the sequence approach if nothing is found (it would still be quicker for most of the cases) I'm not sure what's the best approach is for this, I already made it multithreaded when searching for many image sequences, so it's faster than before, but I'm sure there is room for improvement.
Fastest way to check if an image sequence string actually exists on disk
0.099668
0
0
1,146
32,772,672
2015-09-24T23:45:00.000
0
1
0
1
python,image,file,sequence,exists
32,930,114
2
false
0
0
If there are potentially so many files that you're worried about wasting memory for a dictionary that holds them all, you could just store a single key for each img_seq.###[.suffix].ext pattern, removing the sequence number as you scan the directory. Then a single lookup will suffice. The values in the dictionary could either be "dummy" booleans because the existence of the key is the only thing you care about, or counters in case you ever want to know how many files you have for a certain sequence.
2
0
0
I have a potentially big list of image sequences from nuke. The format of the string can be: /path/to/single_file.ext /path/to/img_seq.###[.suffix].ext /path/to/img_seq.%0id[.suffix].ext, i being an integer value, the values between [] being optional. The question is: given this string, that can represent a sequence or a still image, check if at least one image on disk corresponds to that string in the fastest way possible. There is already some code that checks if these files exist, but it's quite slow. First it checks if the folder exists, if not, returns False Then it checks if the file exists with os.path.isfile, if it does, it returns True. Then it checks if no % or # is found in the path, and if not os.path.isfile, it returns False. All this is quite fast. But then, it uses some internal library which is in performance a bit faster than pyseq to try to find an image sequence, and does a bit more operations depending if start_frame=end_frame or not. But it stills take a large amount of time to analyze if something is an image sequence, specially on some sections of the network and for big image sequences. For example, for a 2500 images sequence, the analysis takes between 1 and 3 seconds. If I take a very naive approach, and just checks if a frame exist by replacing #### by %04d, and loop over 10000 and break if found, it takes less than .02 seconds to check for os.path.isfile(f), specially if the first frame is between 1-3000. Of course I cannot guarantee what the start frame will be, and that approach is not perfect, but in practice many of the sequences do begin between 1-3000, and I could return True if found and fallback to the sequence approach if nothing is found (it would still be quicker for most of the cases) I'm not sure what's the best approach is for this, I already made it multithreaded when searching for many image sequences, so it's faster than before, but I'm sure there is room for improvement.
Fastest way to check if an image sequence string actually exists on disk
0
0
0
1,146
32,772,954
2015-09-25T00:21:00.000
2
0
0
0
python,python-2.7,openpyxl
32,776,318
2
false
0
0
If you want to preserve the integrity of the workbook, ie. retain the formulae, the you cannot use data_only=True. The documentation makes this very clear.
1
6
0
Because I need to parse and then use the actual data in cells, I open an xlsm in openpyxl with data_only = True. This has proved very useful. Now though, having the same need for an xlsm that contains formuale in cells, when I then save my changes, the formulae are missing from the saved version. Are data_only = True and formulae mutually exclusive? If not, how can I access the actual value in cells without losing the formulae when I save? When I say I lose the formulae, it seems that the results of the formulae (sums, concatenattions etc.) get preserved. But the actual formulaes themselves are no longer displayed when a cell is clicked. UPDATE: To confirm whether or not the formulaes were being preserved or not, I've re-opened the saved xlsm, this time with data_only left as False. I've checked the value of a cell that had been constructed using a formula. Had formulae been preserved, opening the xlsm with data_only set to False should have return the formula. But it returns the actual text value (which is not what I want).
How to save in openpyxl without losing formulae?
0.197375
1
0
6,128
32,773,464
2015-09-25T01:40:00.000
17
0
1
0
java,python,arrays,arraylist
32,773,699
2
true
0
0
ArrayList in java and list in python are both dynamic arrays. They both have O(1) average indexing time and O(1) average adding an element to the end time. Array in java is not tuple in python. While it is true that you cannot add elements to both data structures. Python tuple does not support assignment, that is you cannot reassign individual elements in a tuple, while you can in java Array.
2
8
0
I just looked up array and arrayList and found out that an array is fixed length and can't be changed while an arraylist can be changed and is variable in length my question is: is array == tuple in python? and is arraylist == list in python? and if they aren't what are array and arraylist's python equivalent?
Array ArrayList python equivalent
1.2
0
0
33,386
32,773,464
2015-09-25T01:40:00.000
0
0
1
0
java,python,arrays,arraylist
32,773,498
2
false
0
0
Java's ArrayList is similar to Python's List. Nicer than Array for adding and removing items. Java's Array has fixed length like you mentioned. Not sure what its equivalent in Python would be.
2
8
0
I just looked up array and arrayList and found out that an array is fixed length and can't be changed while an arraylist can be changed and is variable in length my question is: is array == tuple in python? and is arraylist == list in python? and if they aren't what are array and arraylist's python equivalent?
Array ArrayList python equivalent
0
0
0
33,386
32,774,520
2015-09-25T03:54:00.000
-1
0
0
0
python,matplotlib
59,199,255
5
false
0
0
Had this problem. You just have to use show() function to show it in a window. Use pyplot.show()
2
26
1
I am using python 2.7.9 on win8. When I tried to plot using matplotlib, the following error showed up: from pylab import * plot([1,2,3,4]) [matplotlib.lines.Line2D object at 0x0392A9D0] I tried the test code "python simple_plot.py --verbose-helpful", and the following warning showed up: $HOME=C:\Users\XX matplotlib data path C:\Python27\lib\site-packages\matplotlib\mpl-data You have the following UNSUPPORTED LaTeX preamble customizations: Please do not ask for support with these customizations active. loaded rc file C:\Python27\lib\site-packages\matplotlib\mpl-data\matplotlibrc matplotlib version 1.4.3 verbose.level helpful interactive is False platform is win32 CACHEDIR=C:\Users\XX.matplotlib Using fontManager instance from C:\Users\XX.matplotlib\fontList.cache backend TkAgg version 8.5 findfont: Matching :family=sans-serif:style=normal:variant=normal:weight=normal:stretch=normal:size=medium to Bitstream Vera Sans (u'C:\Python27\lib\site-packages\matplotlib\mpl-data\fonts\ttf\Vera.ttf') with score of 0.000000 What does this mean? How could I get matplotlib working?
why matplotlib give the error []?
-0.039979
0
0
61,800
32,774,520
2015-09-25T03:54:00.000
0
0
0
0
python,matplotlib
62,611,119
5
false
0
0
When you run plt.plot() on Spider, you will now receive the following notification: Figures now render in the Plots pane by default. To make them also appear inline in the Console, uncheck "Mute Inline Plotting" under the Plots pane options menu. I followed this instruction, and it works.
2
26
1
I am using python 2.7.9 on win8. When I tried to plot using matplotlib, the following error showed up: from pylab import * plot([1,2,3,4]) [matplotlib.lines.Line2D object at 0x0392A9D0] I tried the test code "python simple_plot.py --verbose-helpful", and the following warning showed up: $HOME=C:\Users\XX matplotlib data path C:\Python27\lib\site-packages\matplotlib\mpl-data You have the following UNSUPPORTED LaTeX preamble customizations: Please do not ask for support with these customizations active. loaded rc file C:\Python27\lib\site-packages\matplotlib\mpl-data\matplotlibrc matplotlib version 1.4.3 verbose.level helpful interactive is False platform is win32 CACHEDIR=C:\Users\XX.matplotlib Using fontManager instance from C:\Users\XX.matplotlib\fontList.cache backend TkAgg version 8.5 findfont: Matching :family=sans-serif:style=normal:variant=normal:weight=normal:stretch=normal:size=medium to Bitstream Vera Sans (u'C:\Python27\lib\site-packages\matplotlib\mpl-data\fonts\ttf\Vera.ttf') with score of 0.000000 What does this mean? How could I get matplotlib working?
why matplotlib give the error []?
0
0
0
61,800
32,774,796
2015-09-25T04:25:00.000
2
0
0
0
python,django,solr
32,996,183
1
true
1
0
It seems Django-Haystack does not support SOLR 5 well. SOLR 5's solrconfig.xml file for its core uses ManagedIndexSchemaFactory as default schemaFactory. If you change it to ClassicIndexSchemaFactory, you will run in troubles with your schema.xml which is generated by python manage.py build_solr_schema. Lots of fields' types are not supported. Probably going back to SOLR 4 would be a better choice
1
2
0
Trying to find an example of how to build an application using solr 5.x with django-haystack, but most examples online are using solr 4.x or solr 3.x. Can anyone give some instructions on how to work with solr 5.x using django-haystack, or just offer some example project? Thanks!
Can anyone offer a full example of django-haystack with solr 5.x?
1.2
0
0
520
32,775,445
2015-09-25T05:31:00.000
0
0
1
0
python,oop
32,775,491
2
false
0
0
If you are reading a normal attribute then it doesn't matter. If you are binding a normal attribute then you must use the correct one in order for the code to work. If you are accessing a descriptor then you must use an instance.
1
0
0
I was searching for the meaning of default parameters object,self that are present as default class and function parameters, so moving away from it, if we are calling an attribute of a class should we use Foo (class reference) or should we use Foo() (instance of the class).
What is the functionality difference between the Reference of a class and its object/instance in python while calling its objects?
0
0
0
47
32,776,134
2015-09-25T06:31:00.000
5
0
0
0
python,numpy,pandas,bigdata
32,776,321
1
true
0
0
Memory consumption depends very much on the way data is stored. For example 1 as string takes only one byte, as an int it takes two bytes and eight bytes as double. Then there is the overhead of creating it as in Object of DaataFrame and Series. All this is done for efficient processing. As a general rule of thumb data respresentation in memory will have larger size than in storage. BigData means data which is too large to fit in the memory (or process in a single machine). So it makes no sense to parse the whole data and load it in memory. All BigData processing engines depend splitting the data into chunks and processing the chunks individually (and parallely), then combining these intermediate results into one.
1
0
1
I am new to bigdata, I want to parse the whole data, so I cant split it when i try to use numpy array for processing 1 GB data it takes 4GB memory (In real time I am dealing with huge data). Is there any optimized way to use these array for this much data or any special function to handle huge data.
Why Numpy and Pandas arrays consuming more memory than source data?
1.2
0
0
1,066
32,777,369
2015-09-25T07:53:00.000
0
0
1
1
python,ubuntu,python-import,python-c-extension,python-install
32,778,352
3
false
0
0
I reinstalled Python 3.4 via Ubuntu package system, and suddenly everything worked fine. I still have no clue how Ubuntu customize its own Python, since Python's configure command has no related option at all. Anyway, it works, so why bother :P. Finally, thank you for helping me with this problem.
2
1
0
I installed Python 3.5 from source and broke a number of modules on Python 3.4, which unfortunately, was an essential part of Ubuntu. I've been trying to fix the system, now I'm almost there, with (hopefully) the last problem: My Python 3.4 only recognize C modules with name *.cpython-34m.so, while all packages from Ubuntu repository are named *.cpython-34m-x86_64-linux-gnu.so. It seems that the cpython-34m stuff is the full name of Python, so I need to change it in accord with Ubuntu's expectation. How can I achieve this?
How to change python's "full name" (something like `cpython-34m-x86_64-linux-gnu`)?
0
0
0
348
32,777,369
2015-09-25T07:53:00.000
1
0
1
1
python,ubuntu,python-import,python-c-extension,python-install
32,778,449
3
true
0
0
What you are trying makes no sense. The name cannot be changed, for a good reason. The reason the names are different is to prevent incompatible versions from mixing up each other. You can compile a different version with different options and then the name will be different, too.
2
1
0
I installed Python 3.5 from source and broke a number of modules on Python 3.4, which unfortunately, was an essential part of Ubuntu. I've been trying to fix the system, now I'm almost there, with (hopefully) the last problem: My Python 3.4 only recognize C modules with name *.cpython-34m.so, while all packages from Ubuntu repository are named *.cpython-34m-x86_64-linux-gnu.so. It seems that the cpython-34m stuff is the full name of Python, so I need to change it in accord with Ubuntu's expectation. How can I achieve this?
How to change python's "full name" (something like `cpython-34m-x86_64-linux-gnu`)?
1.2
0
0
348
32,777,714
2015-09-25T08:14:00.000
4
0
1
0
python,qt,pyqt,pyside,cython
32,781,979
1
true
0
0
You can Cythonize your modules file by file if you want to, however all the dependencies will remain the way they are in Python. Cython does not provide a mechanism to embedd all the required modules the way pyinstaller does. This is, however, a bad idea. The general approach for optimization in scientific python is that we port to Cython/C/Fortran parts of the code that are computationally expensive, while keeping the rest in pure Python for convenience. Doing what you propose will be, a) hard to maintain b) slow, as using Cython is more than about compiling the original Python code, you need to do quite a bit of work to get a significant performance gains, and doing that for all of your code is just a waste of time. Bottom line, either use Cython only for parts of your code where this will be beneficial and build your project with pyinstaller etc, or switch to C++ or any other compiled language, if that is what you are looking for.
1
3
0
I have a PySide project with many modules, files and folders. I also used Numpy, Matplotlib and many other modules. I want to build this project with cython. The code is pure python, and i want cython to add all dependencies together, just like when using pyinstaller is it possible or cython is just made for writing extensions (dll, so, lib) ?
how to build whole python project with cython
1.2
0
0
3,039
32,778,316
2015-09-25T08:50:00.000
1
0
1
0
python,vim,intellij-idea
32,778,637
3
true
0
0
It seems that vim used tabs for indentation whereas it is common in Python to use whitespaces. Code -> Reformat Code... in Intellij will make correct indentation. Or you can choose Edit -> Convert Indents and convert tabs to white spaces.
1
1
0
I am a vim user and edited a large python file using vim, everything is OK and it could run properly. Now I want to build a huge projects and I want to edit this python file in Intellij, but the indentation in intellij is completely wrong, and it's hard for me to edit one line by one line. Do you know what happened? (if the edit some lines in Intellij to remove the indentation error, when I display them in vim, they are wrong indentation as well)
python file edited in vim move to intellij meet inconsistent indentation error
1.2
0
0
71
32,778,426
2015-09-25T08:56:00.000
0
0
1
0
python,visual-studio
32,779,409
1
false
0
0
All Python distributions include random module and as it is part of the Python standard library. Unless Python is purposely slimmed down e.g. for embedded environments. But in this case it should not be the case. _random (And all underscore prefixed modules) are native extensions for Python written in C and should not be accessed by the developer directly. Sounds like Community edition is somehow broken installation.
1
1
0
Simple question: When using pip to install a library in the Python Environment window of Visual Studio 2015 Community I find the import statement then requires an underscore. Example Normal Python distribution: import random Community : import _random I also find random.randint() is now not available in the community edition! Are the Visual Studio pip Python libraries different from the standard distributions from the Python web site?
Python Library differences between vendors
0
0
0
73
32,786,482
2015-09-25T16:15:00.000
2
0
0
0
python,django,django-admin
32,786,679
2
true
1
0
If you don't want to use Django's Group and Permission, maybe you don't want to use django.contrib.auth at all? If that is the case, simply remove django.contrib.auth from INSTALLED_APPS. However, I want to point out that I can't really think of a usecase where this would make sense. You have to have a really good reason for writing your own Group and Permission
1
1
0
I want to create my own Group and Permission model. However, Django has its built-in models for this which are giving me naming conflicts on it's own modelGroup. I know you can deregister to remove it from this admin, but this does not help me. What is best here? Is it possible to use Django's own and models for Groups and add to them (i.e add more fields), or can I remove the built-in Group model altogether? My user seems to extend from AbstractBaseUser.
How to remove Group and Permission models from Django
1.2
0
0
3,099
32,786,620
2015-09-25T16:24:00.000
-1
0
0
0
python,mysql,linux,python-2.7
32,786,846
2
false
0
0
Nevermind!!! Apparently I am installing Python and libraries in the right directories and such (I have always used YUM), but apparently there are other versions of Python installed.. need to clean that up. Running: /usr/bin/python All the modules worked! Running: python (Linux finding python in the path somewhere) Modules are not working! Grrr... Maybe I will checking out the Python "Virtual Environments"! Thanks for the suggestions!
2
0
0
Arrghh... I am trying to use mySQL with Python. I have installed all the libraries for using mySQL, but keep getting the: "ImportError: No module named mysql.connector" for "import mysql.connector", "mysql", etc.. Here is my config: I have a RHEL server: Red Hat Enterprise Linux Server release 6.7 (Santiago) with Python 2.7.9 Python 2.7.9 (default, Dec 16 2014, 10:42:10) [GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2 with mySQL 5.1 mysql Ver 14.14 Distrib 5.1.73, for redhat-linux-gnu (x86_64) using readline 5.1 I have all the appropriate libraries/modules installed, I think! yum install MySQL-python Package MySQL-python-1.2.3-0.3.c1.1.el6.x86_64 already installed and latest version yum install mysql-connector-python.noarch Installed: mysql-connector-python.noarch 0:1.1.6-1.el6 yum install MySQL-python.x86_64 Package MySQL-python-1.2.3-0.3.c1.1.el6.x86_64 already installed and latest version yum install mysql-connector-python.noarch Package mysql-connector-python-1.1.6-1.el6.noarch already installed and latest version What am I doing wrong? HELP!?
mySQL within Python 2.7.9
-0.099668
1
0
544
32,786,620
2015-09-25T16:24:00.000
2
0
0
0
python,mysql,linux,python-2.7
32,786,680
2
true
0
0
You should use virtualenv in order to isolate the environment. That way your project libs won't clash with other projects libs. Also, you probably should install the Mysql driver/connector from pip. Virtualenv is a CLI tool for managing your environment. It is really easy to use and helps a lot. What it does is to create all the folders Python needs on a custom location (usually your specific project folder) and it also sets all the shell variables so that Python can find the folders. Your system (/usr and so on) folders are not removed from the shell; rather, they just get a low priority. That is done by correctly setting your PATH variable, and virtualenv does that when you load a determined environment. It is common practice to use an environment for each project you work on. That way, Python and pip won't install libs on the global folders. Instead, pip installs the libs on the current environment you are using. That avoids version conflicts and even Python version conflicts.
2
0
0
Arrghh... I am trying to use mySQL with Python. I have installed all the libraries for using mySQL, but keep getting the: "ImportError: No module named mysql.connector" for "import mysql.connector", "mysql", etc.. Here is my config: I have a RHEL server: Red Hat Enterprise Linux Server release 6.7 (Santiago) with Python 2.7.9 Python 2.7.9 (default, Dec 16 2014, 10:42:10) [GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2 with mySQL 5.1 mysql Ver 14.14 Distrib 5.1.73, for redhat-linux-gnu (x86_64) using readline 5.1 I have all the appropriate libraries/modules installed, I think! yum install MySQL-python Package MySQL-python-1.2.3-0.3.c1.1.el6.x86_64 already installed and latest version yum install mysql-connector-python.noarch Installed: mysql-connector-python.noarch 0:1.1.6-1.el6 yum install MySQL-python.x86_64 Package MySQL-python-1.2.3-0.3.c1.1.el6.x86_64 already installed and latest version yum install mysql-connector-python.noarch Package mysql-connector-python-1.1.6-1.el6.noarch already installed and latest version What am I doing wrong? HELP!?
mySQL within Python 2.7.9
1.2
1
0
544
32,788,716
2015-09-25T18:45:00.000
0
0
0
0
python,excel,openpyxl
32,790,713
1
false
0
0
openpyxl does not support multiple styles within an individual cell.
1
3
0
I wrote a Python program which produces invoices in a specific form as .xlsx files using openpyxl. I have the general invoice form as an Excel workbook and my program copies this form and fills up the details about the specific client (eg. client refernce number, price, etc.) which are read from another .txt file. The program works perfectly. The only problem is that the form contains a cell which has multiple styles: half of the letters are red and the rest black and there is also size difference. This cell is not edited in my program (it is the same in all the invoices), however after the rest worksheet is edited by my program the cell keeps only the first style (the red letters). Why does openpyxl changes this cell since I don't edit it? Does openpyxl support multiple styles, or I have to split the letters with different styles in seperate cells?
Multiple styles in one cell in openpyxl
0
1
0
1,165
32,789,247
2015-09-25T19:22:00.000
1
1
1
0
multithreading,python-2.7,serialization,subprocess
32,807,914
2
false
0
0
There can be different approaches based on the type of architecture and driver. One of them can be as below : As soon as you receive data via receive interrupt, post the data to the main receive buffer queue. There can be a single thread called Rx dispatcher/Rx Manager that always reads the main receive buffer queue and post/dispatch to respective receive queue of reader threads based on msg type/id for further processing. On the transmission side, respective thread can post the data along with msg type/id to the main transmit buffer queue which shall be sent out by Tx thread via transmit interrupt.
1
3
0
I have a serial port which gives me a lot of different data from different pieces of hardware. I need to send different commands to the serial port to receive different kinds of data from it. So, I need to write and read data simultaneously from the port in different functions. Sometimes, I might need to read and write simultaneously from the serial port in 10 different threads. What is the best way of writing code in this situation for simultaneously reading/writing data from a single port? Threads, sub processes, etc.
Reading and writing from a single serial port simultaneously from multiple threads
0.099668
0
0
5,692
32,791,851
2015-09-25T23:03:00.000
20
0
0
0
python,django,postgresql,hstore,jsonb
32,792,698
1
true
1
0
If you need indexing, use jsonb if you're on 9.4 or newer, otherwise hstore. There's really no reason to prefer hstore over jsonb if both are available. If you don't need indexing and fast processing and you're just storing and retrieving validated data, use plain json. Unlike the other two options this preserves duplicate keys, formatting, key ordering, etc.
1
21
0
Django 1.8 provides HStoreField and Django 1.9 will provide JSONField (which uses jsonb) for PostgreSQL. My understanding is that hstore is faster than json, but does not allow nesting and only allows strings. When should one be used over the other? Should one be preferred over the other? Is hstore still the clear winner in performance compared to jsonb?
When should HStoreField be used instead of JSONField?
1.2
0
0
4,193
32,794,943
2015-09-26T07:57:00.000
1
0
0
0
python,ssl,automated-tests,twisted
32,816,518
1
false
0
0
Ultimately Twisted will just speak TLS to a Transport and dump bytes into it; you can specify a pyOpenSSL context object configured however you like. So this is really more of a question about pyOpenSSL or Cryptography. The TLS handshake generally involves generating random data (session keys) at various points. While I think it is probably possible to make OpenSSL do something completely deterministic by plugging in a special ENGINE that generates non-random random data, this is a use-case that the Twisted TLS toolchain is definitely not geared towards. (For example, randomness is always global in OpenSSL, even though the other parts of the SSL stack are local to the SSL_CTX.)
1
0
0
I've written a TLS parser library in C++ which now I need to write unit tests for. The library is simply fed the TLS data stream and it invokes various callbacks on certain events in TLS protocol. I'm searching for a Python implementation of TLS protocol for both client and server sides which allow me to create several deterministic and reproducible TLS data connections with parameters of my choosing (cipher suites, certificates, transmitting different TLS protocol messages, etc) and simultaneously dump the traffic in a raw binary file. Does twisted allow me to create such test setup and if so is there any code sample available to help me jump start this project?
Create a controlled TLS conversation in Python twisted and store it to be used as test data
0.197375
0
1
80
32,796,751
2015-09-26T11:35:00.000
0
0
0
0
python,python-requests,loaded
32,796,957
1
false
1
0
First requests GET will return you the entire page but requests is no a browser, it does not parse the content. When you load a page with the browser, it does usually 10-50 requests for each resource, runs the JavaScript, ....
1
0
0
I want to know if there is a response from requests.get(url) when the page is fully loaded. I did tests with around 200 refreshes of my page and it happens randomly that once or twice the page does not load the footer.
Detect page is fully loaded using requests library
0
0
1
522
32,802,726
2015-09-26T22:39:00.000
0
0
0
0
python-3.x,pygame
32,802,814
1
false
0
1
Is it possible to make camera tracking without moving the whole world? No. By relativity, moving the player within the world is the same as moving the world around the player. Since your camera is fixed on the player, by definition you will see the world moving when the player moves within it. Therefore, you must draw your world in a different place. It is more explicit in 3D graphics; we represent the scene's motion as one matrix, and the camera's as another. The renderer uses their product. It doesn't care which contributed to the motion.
1
0
0
I don't really want to move the whole world in my game but I do want the screen to follow my character. So for example, normally pygame would render at the position of 0,0 and the window height width would allow you to expand that viewing area. But I want to move the starting position so that I can view something at coordinates 1000x1000 even if my screen is only 500x500 big.
Is it possible to make camera tracking without moving the whole world?
0
0
0
24
32,803,057
2015-09-26T23:27:00.000
1
0
1
1
python,macos,ubuntu,virtualenv
32,803,088
1
true
0
0
It's not possible, because virtualenv use absolute paths to setup the environment. Also it's kind of the reverse of what virtualenv is created for.
1
1
0
Is it possible to set up a virtualenv on a Dropbox folder from a Mac and activate that from Ubuntu that also has access to that Dropbox folder? I seem to be able to call source env/bin/activate and it activates the environment, but when I call which python, it gives me /usr/bin/python instead of the one in the virtual environment Before I do anymore troubleshooting/add more details, is this possible at all and am I just doing something wrong or is this not possible?
python virtualenv set up from mac - use it in linux
1.2
0
0
57
32,804,410
2015-09-27T03:53:00.000
0
0
1
1
python,web-scraping,pip,virtualenv
32,820,352
2
false
0
0
After upgrading the python3.4 package in Ubuntu 14.04 I get the same error. A quick solution is to delete and re-create the virtualenv.
2
0
0
I have virtualenv-13.1.2 set up with python 3.4 (global python is python-2.7) in ubuntu 14.04. When I try to install GoogleScraper using coammandpip install GoogleScraper it gives an error setuptools must be installed to install from a source distribution If I do pip install setuptools Requirement already satisfied (use --upgrade to upgrade): setuptools in ./env/lib/python3.4/site-packages If I do pip install setuptools --upgrade Requirement already up-to-date: setuptools in ./env/lib/python3.4/site-packages How can I successfully install GoogleScraper?
GoogleScraper Installation error - setuptools must be installed
0
0
0
589
32,804,410
2015-09-27T03:53:00.000
1
0
1
1
python,web-scraping,pip,virtualenv
32,836,035
2
true
0
0
I was missing python3-dev tools. I did sudo apt-get install python3-dev and it worked like a charm.
2
0
0
I have virtualenv-13.1.2 set up with python 3.4 (global python is python-2.7) in ubuntu 14.04. When I try to install GoogleScraper using coammandpip install GoogleScraper it gives an error setuptools must be installed to install from a source distribution If I do pip install setuptools Requirement already satisfied (use --upgrade to upgrade): setuptools in ./env/lib/python3.4/site-packages If I do pip install setuptools --upgrade Requirement already up-to-date: setuptools in ./env/lib/python3.4/site-packages How can I successfully install GoogleScraper?
GoogleScraper Installation error - setuptools must be installed
1.2
0
0
589
32,806,238
2015-09-27T09:01:00.000
0
1
0
1
python-2.7,mechanize-python
32,806,729
2
false
0
0
It sounds like you are trying to download the file into memory but you don't have enough. Try using the retrieve method with a file name to stream the downloaded file to disc.
2
0
0
I am trying to download some files via mechanize. Files smaller than 1GB are downloaded without causing any trouble. However, if a file is bigger than 1GB the script runs out of memory: The mechanize_response.py script throws out of memory at the following line self.__cache.write(self.wrapped.read()) __cache is a cStringIO.StringIO, It seems that it can not handle more than 1GB. How to download files larger than 1GB? Thanks
python mechanize retrieving files larger than 1GB
0
0
0
304
32,806,238
2015-09-27T09:01:00.000
0
1
0
1
python-2.7,mechanize-python
32,808,075
2
false
0
0
I finally figured out a work around. Other than using browser.retrieve or browser.open I used mechanize.urlopen which returned the urllib2 Handler. This allowed me to download files larger than 1GB. I am still interested in figuring out how to make retrieve work for files larger than 1GB.
2
0
0
I am trying to download some files via mechanize. Files smaller than 1GB are downloaded without causing any trouble. However, if a file is bigger than 1GB the script runs out of memory: The mechanize_response.py script throws out of memory at the following line self.__cache.write(self.wrapped.read()) __cache is a cStringIO.StringIO, It seems that it can not handle more than 1GB. How to download files larger than 1GB? Thanks
python mechanize retrieving files larger than 1GB
0
0
0
304
32,808,686
2015-09-27T13:58:00.000
6
0
1
0
python,random
32,809,283
1
true
0
0
You can save the state of the PRNG using random.getstate() (then, e.g., use pickle to save it to disk. Later, a random.setstate(state) will return your PRNG to exactly the state it was in.
1
4
1
I'm designing a program which: Includes randomness Can stop executing and save its state at certain points (in XML) Can start executing starting from a saved state Is deterministic (so the program can run from the same state twice and produces the same result) The problem here is saving the randomness. I can initialize it at start, but from state to state I may generate anywhere from 0 to 1000 random numbers. Therefore, I have 3 options I can see: Store the seed, and number of times a number has been randomly generated, then when loading the state, run the random number generator that many times. On state save, increment the seed by N On state save, randomly generate the next seed The problem with option 1 is the run time, and is pretty infeasible. However, I'm unsure whether 2 or 3 will produce good random results. If I run two random generators, one seeded with X, the other seeded with X+1, how different will their results be? What if the first is seeded with X, and the second is seeded with X.random()? In case it makes a difference, I'm using Python 3.
Storing a Random state
1.2
0
0
2,249
32,811,713
2015-09-27T19:02:00.000
7
0
1
1
python,python-3.x,python-2.7,osx-yosemite
32,811,789
7
false
0
0
As long as you keep your installation folders organized, you should have no issues having both on your computer, besides one thing. The path environment variable for python will determine which version is used by default, so I would say stick to one version, or make sure to make your programs as backwards compatible as possible. I have run into this issue on Windows, since I installed Python 3.4 before 2.7, and therefore to run older code, I have to manually select the python executable. In terms of libraries, I believe that for each python version, the libraries are completely separate, so you should be good there.
6
16
0
Supposedly Python 2.7 is included native to OSX 10.8 and above (if I remember correctly), but I recently installed Python 3.5 to use for projects while I work through UDacity. Lo and behold, the UDacity courses seem to use 2.7 - wups! So instead of trying to uninstall 3.5 (this procedure seemed to scary for neophytes such as myself), I simply installed 2.7 in addition to the recently installed 3.5 and just run the 2.7 IDLE and Shell. Is this ok, or will I run into problems down the road?
Is it ok to install both Python 2.7 and 3.5?
1
0
0
50,311
32,811,713
2015-09-27T19:02:00.000
17
0
1
1
python,python-3.x,python-2.7,osx-yosemite
32,823,074
7
true
0
0
I have installed two versions, 2.7, 3.4 and I do not have any problem by now. 3.4 I am using for my work project in eclipse environment, 2.7 for udacity course, like You ;).
6
16
0
Supposedly Python 2.7 is included native to OSX 10.8 and above (if I remember correctly), but I recently installed Python 3.5 to use for projects while I work through UDacity. Lo and behold, the UDacity courses seem to use 2.7 - wups! So instead of trying to uninstall 3.5 (this procedure seemed to scary for neophytes such as myself), I simply installed 2.7 in addition to the recently installed 3.5 and just run the 2.7 IDLE and Shell. Is this ok, or will I run into problems down the road?
Is it ok to install both Python 2.7 and 3.5?
1.2
0
0
50,311
32,811,713
2015-09-27T19:02:00.000
1
0
1
1
python,python-3.x,python-2.7,osx-yosemite
38,431,312
7
false
0
0
Im not sure about OSX, but with windows 10 my environment variables for 2.7 were overwritten with the 3.5 path. Not a tough fix, but a little confusing, since it was months later when I needed 2.7 again.
6
16
0
Supposedly Python 2.7 is included native to OSX 10.8 and above (if I remember correctly), but I recently installed Python 3.5 to use for projects while I work through UDacity. Lo and behold, the UDacity courses seem to use 2.7 - wups! So instead of trying to uninstall 3.5 (this procedure seemed to scary for neophytes such as myself), I simply installed 2.7 in addition to the recently installed 3.5 and just run the 2.7 IDLE and Shell. Is this ok, or will I run into problems down the road?
Is it ok to install both Python 2.7 and 3.5?
0.028564
0
0
50,311
32,811,713
2015-09-27T19:02:00.000
3
0
1
1
python,python-3.x,python-2.7,osx-yosemite
38,438,902
7
false
0
0
As others have said, if the installation directory is different it should be no problem at all. One thing that'll make your life easier for switching between the two is to use an IDE such as PyCharm, you just have to change a drop down to switch between the two versions.
6
16
0
Supposedly Python 2.7 is included native to OSX 10.8 and above (if I remember correctly), but I recently installed Python 3.5 to use for projects while I work through UDacity. Lo and behold, the UDacity courses seem to use 2.7 - wups! So instead of trying to uninstall 3.5 (this procedure seemed to scary for neophytes such as myself), I simply installed 2.7 in addition to the recently installed 3.5 and just run the 2.7 IDLE and Shell. Is this ok, or will I run into problems down the road?
Is it ok to install both Python 2.7 and 3.5?
0.085505
0
0
50,311
32,811,713
2015-09-27T19:02:00.000
2
0
1
1
python,python-3.x,python-2.7,osx-yosemite
34,581,673
7
false
0
0
It should be fine. Its actually pretty common to have multiple Python environments. It helps to prevent dependency conflicts between your projects. That is what is happening when you are using tools like pyenv and virtualenv. Using tools like pyenv and virtualenv may also help you with the path problems that others mentioned. They have commands to set up the path so that their version of pip, python, etc are used.
6
16
0
Supposedly Python 2.7 is included native to OSX 10.8 and above (if I remember correctly), but I recently installed Python 3.5 to use for projects while I work through UDacity. Lo and behold, the UDacity courses seem to use 2.7 - wups! So instead of trying to uninstall 3.5 (this procedure seemed to scary for neophytes such as myself), I simply installed 2.7 in addition to the recently installed 3.5 and just run the 2.7 IDLE and Shell. Is this ok, or will I run into problems down the road?
Is it ok to install both Python 2.7 and 3.5?
0.057081
0
0
50,311
32,811,713
2015-09-27T19:02:00.000
0
0
1
1
python,python-3.x,python-2.7,osx-yosemite
34,580,951
7
false
0
0
I have the same problem and it is not necessary to uninstall on version of python. Please take care to not mix them up - When you search them up on the start menu. You can make a desktop shortcut saying 2.6 and 3.5.
6
16
0
Supposedly Python 2.7 is included native to OSX 10.8 and above (if I remember correctly), but I recently installed Python 3.5 to use for projects while I work through UDacity. Lo and behold, the UDacity courses seem to use 2.7 - wups! So instead of trying to uninstall 3.5 (this procedure seemed to scary for neophytes such as myself), I simply installed 2.7 in addition to the recently installed 3.5 and just run the 2.7 IDLE and Shell. Is this ok, or will I run into problems down the road?
Is it ok to install both Python 2.7 and 3.5?
0
0
0
50,311
32,811,951
2015-09-27T19:26:00.000
0
0
0
0
python,printing,tkinter
32,812,217
1
false
0
1
No, there is not. You'll have to create your own popup window for that specific problem.
1
0
0
Is there a command in Tkinter that allows the program to pop up a window that lets the user pick a printer from the list of drivers that they have installed? Sorry that I can't provide any details, but I haven't found anything about this topic on the web.
Tkinter Print function[filedialog]
0
0
0
62
32,812,765
2015-09-27T20:57:00.000
2
0
1
0
python,ide,format,spyder
33,624,414
1
false
1
0
I tried this Source -> Fix Indentation, Remove Trailing Spaces This is not the most efficient way, but it seems there are no key combinations to do these. Even in preferences, they have not allowed to add new shortcut for this.
1
3
0
Can anyone please advice the key combination to format python code in annaconda/Spyder IDE? In Eclipse IDE when coding in Java I usually use command F, however in Spyder IDEthe key combination causes search window to pop up.
Format python code in Spyder IDE
0.379949
0
0
5,911
32,813,107
2015-09-27T21:37:00.000
3
0
1
0
python,function,module
32,813,261
1
false
0
0
Code should be made to be easily readable by a human; Readability counts (from The Zen of Python). Stick to the conventions of PEP-8, unless you have good reason not to do so. My suggestion would be to start with the main parts of the module in a sequence that makes sense for this particular module. Helper functions and classes go below that in a top-down fashion. Modern editors are quite capable of finding function or method definitions in code, so the precise sequence under the top level doesn't matter as much as they used to. If your editor supports it consider using folding.
1
1
0
I've fully graduated from writing scripts to writing modules. Now that I have a module full of functions, I'm not quite sure if I should order them in some way. Alphabetical seems to make sense to me, but I wanted to see if there were others schools of thought on how they should be ordered in a module. Maybe try to approximate the flow of the code or some other method? I did some searching on this and didn't really find anything, except for that functions need to be defined before calling them, which isn't really relevant to my question. Thanks for any thoughts people can provide!
Pythonic way to order functions within a module
0.53705
0
0
1,354
32,813,646
2015-09-27T22:49:00.000
0
0
0
0
python,selenium,beautifulsoup
32,815,252
1
false
1
0
These are completely different tools that, in general, cannot be considered alternatives, though they somewhat cross on the "Locating Elements" front. The located elements though are very different - one is a Tag instance in BeautifulSoup and the other one is a webdriver WebElement instance that can actually be interacted with it is "live". Both tools support CSS selectors. The support is quite different, but if you don't go in depth with things like multiple attribute checks (a[class*=test1][class^=test] - not gonna work in BeautifulSoup, for instance), nth-child, nth-of-type, going sideways with + etc, you can assume things are gonna work on both ends. Please add examples of the elements you want to correlate and we can work through them.
1
3
0
I am using Selenium to navigate a webpage. To analyze the elements and data, I use BeautifulSoup because of the excellent options they give, including searching with regex. So now I have an element located in BeautifulSoup. I want to select it in Selenium. I figured I could somehow pass a XPath or CSS selector from the BeautifulSoup element to the Selenium element. Is there a direct way of going from a BeautifulSoup element to Selenium element?
Send element from BeautifulSoup to Selenium
0
0
1
386
32,816,538
2015-09-28T06:00:00.000
1
0
1
0
python,python-2.7,python-imaging-library
36,235,535
1
false
0
0
Hey Just recompile your python with option ./configure --enable-unicode=ucs2, It will be get fixed.
1
5
0
I have installed python2.7 and while executing my application getting error as like /usr/local/lib/python2.7/site-packages/PIL/_imaging.so: undefined symbol: PyUnicodeUCS2_AsLatin1String Also i checked by build and displays as 'UCS2' How can we resolve this.
undefined symbol: PyUnicodeUCS2_AsLatin1String
0.197375
0
0
2,097
32,816,966
2015-09-28T06:36:00.000
0
0
0
0
python,django,django-models
32,830,790
2
false
1
0
it is not clear what you mean by "my user" . is this just the admin user who set this configuration globaly for the site . or do you mean evey user of the site has his/her own preferences ? if the latter case then make a new model called Preferences which has one to one relation to the user model . then in your query you should create three separate queries according to the preference values .
1
1
0
suppose i have three models, at my view I am showing all the item of these models, i want to give my user privilege to set which model's objects are to be shown at view at first, second and third. what is the best way to implement this?
how to keep django models in database for users customized view?
0
0
0
106
32,817,302
2015-09-28T06:59:00.000
0
0
0
1
python,linux,macos,terminal,stdout
32,818,127
2
false
0
0
File write operations are buffered by default so the file isn't effectiveley written until either the buffer is full, the file is closed or you explicitely call flush() on the file. But anyway: dont use direct file access if you want to log to a file, use either a logging.StreamHandler with an opened file as stream or, better, a logging.FileHandler. Both will take care of flushing the file.
1
6
0
This is a python question, but also a linux/BSD question. I have a python script with two threads, one downloading data from the web and the other sending data to a device over a serial port. Both of these threads print a lot of status information to stdout using python's logging module. What I would like is to have two terminal windows open, side by side, and have each terminal window show the output from one thread, rather than have the messages from both interleaved in a single window. Are there file descriptors other than stdin, stdout & stderr to write to and connect to other terminal windows? Perhaps this wish is better fulfilled with a GUI? I'm not sure how to get started with this. edit: I've tried writing status messages to two different files instead of printing them to stdout, and then monitoring these two files with tail -f in other terminal windows, but this doesn't work for live monitoring because the files aren't written to until you call close() on them.
Is it possible to output to and monitor streams other than stdin, stdout & stderr? (python)
0
0
0
437
32,818,009
2015-09-28T07:47:00.000
1
0
1
0
python,ipython,pycharm
32,950,379
1
false
0
0
I've had the same problem and have a partial solution. To include your file, add the following to a cell: execfile("superSource.py"). This should load and execute it and make its contents available for reuse so that you can access variable and call functions defined or imported by it in other cells. Unfortunately, PyCharm does not know about it, so that as you type, there is no statement completion and if you have "Show import popup" enabled in PyCharm, it will suggest adding an import but highlight it as an error afterwards. It should still work, however.
1
0
0
Within my project XYZ, I have a file superSource.py, which contains some functions. Now, I've used the new cool pyCharm feature of creating an IPython notebook, which I calltest test.ipynb, and saved it in the projects main directory (next to superSource.py). However, when I run import superSource; foo = superSource.parameters() nothing happens, I don't even get a warning. pyCharm will underline superSource within the code though, warning me that there is no module called superSource. How can I include other files from the same directory using the IPython notebook and/or pyCharm?
PyCharm and IPython Notebook: Include files from project
0.197375
0
0
336
32,820,673
2015-09-28T10:21:00.000
1
0
1
1
python,windows,uninstallation
32,821,417
2
true
0
0
Did you try to reinstall the version you want to delete and then uninstall it afterwards ?
1
3
0
I accidentally downloaded Python 3.4.2 a while back but I actually needed Python 2.7, so I deleted the 3.4.2 files and downloaded 2.7 instead. Now I need Python 3, so I tried to download it but I noticed that in the control panel in the Uninstall Programs section it tells me that the 3.4.2 from back then is still on my PC. Every time I try to uninstall/change/repair/download a newer version I can't and it tells me A program required to complete the installation can not be found... I can not find any remaining files connected to any sort of Python in my PC. My operating system is Windows 10. Does someone know how to solve this?
Can't uninstall Python on Windows (3.4.2)
1.2
0
0
8,420
32,820,862
2015-09-28T10:31:00.000
1
0
1
0
python,swap,system-calls
32,830,257
1
true
0
0
For CPython, there is no good answer for this that doesn't involve writing a Python C extension, since mlock works on pages, not objects. The internals of the str object differ from version to version (in Py3.3 and higher, a str may actually have several copies of the data in memory in different encodings, some inlined after the object structure, some dynamically allocated separately and linked by pointer), and even if you used ctypes to retrieve the necessary addresses and mlock-ed them all through ctypes mlock calls, you'll have a hell of a time determining when to mlock and when to munlock. Since mlock works on pages, you'd have to carefully track how many strings are currently in any given page (because if you just mlock and munlock blindly, and there are more than one things to lock in a page, the first munlock would unlock all of them; mlock/munlock is a boolean flag, it doesn't count the number of locks and unlocks). Even if you manage that, you still would have a race between password acquisition and mlock during which the data could be written to swap, and those cached alternate encodings are computed lazily, so mlocking the non-NULL pointers at any given time doesn't necessarily mean those pointers might not be populated later. You could partially avoid these problems through careful use of the mmap module and memoryviews (mmap gives you pages of memory, memoryview references said memory without copying it, so ctypes could be used to mlock the page), but you'd have to build it all from scratch (can't use the getpass module because it would store as a str for a moment). In short, Python doesn't care about swapping or memory protection in the way you want; it trusts the swap file to be configured to your desired security (e.g. disabled or encrypted), neither providing additional protection nor providing the information you'd need to add it in.
1
7
0
I'm working on a password manager application for linux and I'm using Python for it. Because of the security reasons I want to call ‍mlock‍‍ system call in order to avoid swapping password variable on hard drive. I noticed that python itself didn't wrap this function. so is there any way so can I avoid swapping? Thanks
mlock a variable in python
1.2
0
0
1,295
32,824,889
2015-09-28T13:57:00.000
0
1
0
1
python,c,bluetooth-lowenergy,dbus,bluez
34,717,559
2
false
0
0
Something more to consider: the latest BlueZ (eg. 5.36+), BLE should work fine and has been very stable for me - and remember to add "experimental" when building it and "-E" as a service parameter to get manufacturerData (and other experimental features) Using the C API, I think your code must be GPL (not 100% sure tho). The DBus interface allows you to make closed source code (if it's for a company)
2
4
0
For a project I am doing I have to connect my Linux PC to a Bluetooth LE device. The application I design will be deployed on an ARM embedded system when it is complete. Searching for documentation online hints that the preferred programming language for these kind of applications is Python. All the Bluez /test examples are written in Python and there are quite a few sources of information regarding creating BLE applications in Python. Not so much in C. My superior and I had an arguement about whether I should use Python or C. One of his arguments was that there was unacceptable overhead when using Python for setting up Bluetooth LE connections and that Bluetooth LE had to be very timely in order to function properly. My argument was that the overhead would not matter as much, since there were no time constraints regarding bluetooth LE connections; The application will find devices, connect to a specific one and read a few attributes, which it saves to a file. My question is; is there any reason to prefer the low-level C approach over using a high-level Python implementation for a basic application that reads GATT services and their characteristics? What would the implications be for an embedded device?
Dbus & Bluez programming language
0
0
0
1,918
32,824,889
2015-09-28T13:57:00.000
3
1
0
1
python,c,bluetooth-lowenergy,dbus,bluez
32,861,048
2
true
0
0
This is quite an open question as there are so many things to consider when making this decision. So the best "answer" might rather be an attempt to narrow down the discussion: Based on the question, I'm making the assumption that the system you are targeting has D-Bus and Python available with all needed dependencies. I'd try to narrow down the discussion by first deciding on what BlueZ API to use. If you are planning on using the D-Bus API rather than the libbluetooth C library API, then there is already some overhead introduced by that and I don't believe Python in itself would be the major factor. That should of course be measured/evaluated to know for sure, but ruling out Python while still using D-Bus might be a premature optimization without much impact in practice. If the C library API is to be used in order to avoid D-Bus overhead then I think you should go with C for the client throughout. If the "timely manner" factor is very important I believe you will eventually need to have ways to measure performance anyway. Then perhaps a proof of concept of both design options might be the best way to really decide. If the timing constraints turn out to be a moot question in practice, other aspects should weigh in more, e.g. ease of development (documentation and examples available), testability, and so on.
2
4
0
For a project I am doing I have to connect my Linux PC to a Bluetooth LE device. The application I design will be deployed on an ARM embedded system when it is complete. Searching for documentation online hints that the preferred programming language for these kind of applications is Python. All the Bluez /test examples are written in Python and there are quite a few sources of information regarding creating BLE applications in Python. Not so much in C. My superior and I had an arguement about whether I should use Python or C. One of his arguments was that there was unacceptable overhead when using Python for setting up Bluetooth LE connections and that Bluetooth LE had to be very timely in order to function properly. My argument was that the overhead would not matter as much, since there were no time constraints regarding bluetooth LE connections; The application will find devices, connect to a specific one and read a few attributes, which it saves to a file. My question is; is there any reason to prefer the low-level C approach over using a high-level Python implementation for a basic application that reads GATT services and their characteristics? What would the implications be for an embedded device?
Dbus & Bluez programming language
1.2
0
0
1,918
32,826,166
2015-09-28T15:02:00.000
1
1
1
0
python,python-2.7,unit-testing,python-3.x
32,826,392
2
false
0
0
If you don't inherit from unit.TestCase, the testing framework won't know that you want those classes to be test cases. So when you try to run your tests, nothing will happen!
1
1
0
What's the motivation behind having my unit test classes inherit from unittest.TestCase, rather than object? Does it matter if I'm using Nose (or PyTest) instead of unittest?
Why inherit from unittest.TestCase?
0.099668
0
0
212
32,826,262
2015-09-28T15:07:00.000
0
0
0
1
python,ffmpeg
32,859,122
1
true
0
0
I run python ***.py in the CMD is OK.Should`t run the program in the PyCharm.Perhaps the environment is differnet.
1
1
0
I had installed ffmpeg in WIN7 64bit. When I use os.system("ffmpeg -i rtsp://218.204.223.237:554/live/1/66251FC11353191F/e7ooqwcfbqjoo80j.sdp -c copy dump.mp4") in my program by the PyCharm,it can also run but I can`t play the dump.mp4. I can run the same command in CMD or Python(command line) and get the dump.mp4 successfully.Why? How can I solve this problem?Can you help me ? I just use Python not long before.
Python ffmpeg on Windows
1.2
0
0
1,646
32,826,804
2015-09-28T15:38:00.000
0
0
0
0
python,freebsd
32,839,165
1
false
0
0
It seems like you mixed 32 and 64bit libraries. I suggest cleaning up the wrong libraries (at least libz seems to be affected) and restoring them from backup/installation medium
1
1
0
I want to install py-MySQLdb but I always get the same lib error.. Any suggestions? Thanks in advance ImportError: /usr/lib/libz.so.6: unsupported file layout *** [do-configure] Error code 1 Stop in /usr/ports/databases/py-MySQLdb. *** [install] Error code 1 Stop in /usr/ports/databases/py-MySQLdb.
FreeBSD 9.3 ImportError while installing py-MySQLdb
0
1
0
226
32,831,050
2015-09-28T20:15:00.000
0
0
1
0
python,debugging,pycharm
60,892,355
4
false
0
0
Try pydevd.settrace() as a first line of the function you try to debugging, or right after deepcopy()
1
4
0
PyCharm's debugger works perfectly, except when hitting lines that contain the built-in method copy.deepcopy(). Stepping over them causes the program to run to conclusion, as if no debugger were running. I have tried stepping into deepcopy(), but I always seem to get caught in a recursive loop. The code runs fine, debugger or no debugger, I just cannot run the debugger after an deepcopy() operations, which is irritating. pdb.set_trace() works fine, but ultimately I'd like to use PyCharm's debugger, and I'm REALLY curious as to what is happening here.
PyCharm's debugger gives up when hitting copy.deepcopy()
0
0
0
520
32,831,111
2015-09-28T20:18:00.000
3
0
0
1
python,rabbitmq,celery
58,830,493
2
false
1
0
Best option is to use celery.send_task from the producing server, then deploy the workers onto n instances. The workers can then be run as @ealeon mentioned, using celery -A proj worker -l info -Ofair. This way, load will be distributed across all servers without having to have the codebase present on the consuming servers.
1
6
0
I'm running celery on multiple servers, each with a concurrency of 2 or more and I want to load balance celery tasks so that the server that has the lowest CPU usage can process my celery tasks. For example, lets say I have 2 servers (A and B), each with a concurrency of 2, if I have 2 tasks in the queue, I want A to process one task and B to process the other. But currently its possible that the first process on A will execute one task and the second process on A will execute the second task while B is sitting idle. Is there a simple way, by means of celery extensions or config, that I can route tasks to the server with lowest CPU usage?
How to load balance celery tasks across several servers?
0.291313
0
0
4,182
32,832,056
2015-09-28T21:23:00.000
2
0
1
0
python
46,797,129
1
false
0
0
Based on my understanding, threads cannot be executed in parallel (executed based on availability and random) Correct and thats the reason Eventlet are being used. Not so correct. The Eventlet library is used to simplify non-blocking IO programming. It does not actually add parallelism. Thread execution is still limited to one thread at a time due to the GIL. But it is used because it greatly simplifies the process of launching, scheduling, and managing IO-bound threads, particularly ones that do not need to interact with each other. If Eventlets are more for parallelism As I just mentioned, this is not what they exist for. why can't we just use multiprocessing module of Python. I thought of executing multi process modules and use the join method() to check if all the process are complete. You certainly can! And you will get actual parallel execution with this approach. But you may not get the same speedup. The multiprocessing library is better suited for CPU-bound parallel tasks, because those are the ones that need more frequent access to the interpreter. You may actually see an increase in execution time when using multiprocessing with IO-bound tasks because of the overhead of multiple process execution and management. As is the case with most optimization and execution time questions, trying both and profiling is the surefire way to guarantee you're using the "best" option for your application. Though you may find that if you write the code to utilize Eventlets first, then try to modify it to use regular threads or multiprocessing, you'll have to write more boilerplate code just to manage the threads or processes, and the value of Eventlets should become more obvious.
1
7
0
Based on my understanding, threads cannot be executed in parallel(executed based on availability and random) and thats the reason Eventlet are being used. If Eventlets are more for parallelism why can't we just use multiprocessing module of Python. I thought of executing multi process modules and use the join method() to check if all the process are complete. Can someone explain if my understanding is correct?
Python Multiprocessing vs Eventlet
0.379949
0
0
981
32,832,062
2015-09-28T21:23:00.000
3
0
1
0
python,pycharm,interpreter,python-3.5
32,832,234
7
false
0
0
When creating a project in PyCharm, if the interpret is not already selected, in the drop down menu under the projects "Location:", you can click the gear-looking icon to the right of the interpreter option, and click "Add Local"; then select the file location of the python.exe file that you have installed. It will probably be C:\Python35\Python.exe
5
16
0
I'm new to programming and just started a course on Python. I want to use PyCharm, so I downloaded and intalled it (v. 4.5, community edition). I had previously installed Python 3.5 64-bit from python.org (I'm using Windows 10). To start using PyCharm, I need a project interpreter, which I can select in the settings. As far as I'm concerned, the interpreter is "py.exe", but when I select it, I get this error message: "The selected file is not a valid home for Python SDK". I also tried to use every file whose name contained "python" or "py", and failed. On every website and video I see, they select a file called "python.exe", but they're using Python 3.4 or a previous version. I checked that PyCharm supports 3.5 ("Initial support for Python 3.5"). Is there anything I'm doing wrong? What should I do to be able to use PyCharm? All replies are appreciated. Thanks in advance.
PyCharm doesn't detect interpreter
0.085505
0
0
53,023
32,832,062
2015-09-28T21:23:00.000
0
0
1
0
python,pycharm,interpreter,python-3.5
38,293,191
7
false
0
0
I have had the exact same problem and was unable to find the solution until just now. Hopefully this works for anyone that was struggling with it. I went to the location of the Python 3.5 (32-Bit) in my C: Drive which it turns out is just a shortcut to the actual Python application, right click on it and select Open file location which should direct you to the application version of python - simply called 'python'. This is the .exe file that PyCharm was looking for to use as the interpreter. Now go to the configure interpreter menu in Pycharm and type in the file location of the actual python application. To get to mine I had to go to AppData/Local/Programs/Python/Python35-32. Click on the python.exe file and it should work. This is my first post here so if its formatted incorrectly or doesn't use the conventional terms - sorry. Let me know if the solution worked for anyone else with the problem or if I fluked it.
5
16
0
I'm new to programming and just started a course on Python. I want to use PyCharm, so I downloaded and intalled it (v. 4.5, community edition). I had previously installed Python 3.5 64-bit from python.org (I'm using Windows 10). To start using PyCharm, I need a project interpreter, which I can select in the settings. As far as I'm concerned, the interpreter is "py.exe", but when I select it, I get this error message: "The selected file is not a valid home for Python SDK". I also tried to use every file whose name contained "python" or "py", and failed. On every website and video I see, they select a file called "python.exe", but they're using Python 3.4 or a previous version. I checked that PyCharm supports 3.5 ("Initial support for Python 3.5"). Is there anything I'm doing wrong? What should I do to be able to use PyCharm? All replies are appreciated. Thanks in advance.
PyCharm doesn't detect interpreter
0
0
0
53,023
32,832,062
2015-09-28T21:23:00.000
0
0
1
0
python,pycharm,interpreter,python-3.5
40,060,261
7
false
0
0
If you kept the default settings while installing python, Your project interpreter for PyCharm will be: C:\Users\yourUserName\AppData\Local\Programs\Python\Python36\python.exe Chose the above location as your project interpreter inside PyCharm. Depending on which python version you have, it could be either Python36\python.exe or Python35\python.exe.
5
16
0
I'm new to programming and just started a course on Python. I want to use PyCharm, so I downloaded and intalled it (v. 4.5, community edition). I had previously installed Python 3.5 64-bit from python.org (I'm using Windows 10). To start using PyCharm, I need a project interpreter, which I can select in the settings. As far as I'm concerned, the interpreter is "py.exe", but when I select it, I get this error message: "The selected file is not a valid home for Python SDK". I also tried to use every file whose name contained "python" or "py", and failed. On every website and video I see, they select a file called "python.exe", but they're using Python 3.4 or a previous version. I checked that PyCharm supports 3.5 ("Initial support for Python 3.5"). Is there anything I'm doing wrong? What should I do to be able to use PyCharm? All replies are appreciated. Thanks in advance.
PyCharm doesn't detect interpreter
0
0
0
53,023
32,832,062
2015-09-28T21:23:00.000
0
0
1
0
python,pycharm,interpreter,python-3.5
58,375,447
7
false
0
0
For me the following solution it worked: My configuration: Pycharm Community edition 2019.1.1 Anaconda distribution with python 3.7. Interpreter in standard location. Problem: Pycharm was not able to find python interpreter after reinstallation of anaconda distribution. Solution: - Make sure you run pycharm as admin (right click and run as admin). This was actually the critical step. - Create new project (or open an existing one) - Depending on the choice choose interpter or go to file > settings > project interpreter > choose small gear on rights side > add > on base interpreter choose the 3 dots > paste the location of the interpreter in the anaconda distribution. Hope it helped someone. For me the blocking point was that for some reason pycharm was not launching with admin rights. Blockquote
5
16
0
I'm new to programming and just started a course on Python. I want to use PyCharm, so I downloaded and intalled it (v. 4.5, community edition). I had previously installed Python 3.5 64-bit from python.org (I'm using Windows 10). To start using PyCharm, I need a project interpreter, which I can select in the settings. As far as I'm concerned, the interpreter is "py.exe", but when I select it, I get this error message: "The selected file is not a valid home for Python SDK". I also tried to use every file whose name contained "python" or "py", and failed. On every website and video I see, they select a file called "python.exe", but they're using Python 3.4 or a previous version. I checked that PyCharm supports 3.5 ("Initial support for Python 3.5"). Is there anything I'm doing wrong? What should I do to be able to use PyCharm? All replies are appreciated. Thanks in advance.
PyCharm doesn't detect interpreter
0
0
0
53,023
32,832,062
2015-09-28T21:23:00.000
12
0
1
0
python,pycharm,interpreter,python-3.5
55,796,938
7
false
0
0
file > new project settings > project Interpreter > click in the drop down and select 'show all' > click the '+' button > Now, in the Virtualenv Environment tab under the New environment radio button, check the path in the 'Base interpreter:' field. For me, mine was set to an invalid path. Once I had corrected the path to point to python.exe I recreated my new project and PyCharm built the virtualenv. For me there was a bit more too.... When creating the new project I expanded the drop down and had to verify the directory where the venv directory was being created. Once I had corrected the path here I had to click around a bit to get it to let me create the project. I'm going to chaulk this up to a bug. I'm using Community edition.
5
16
0
I'm new to programming and just started a course on Python. I want to use PyCharm, so I downloaded and intalled it (v. 4.5, community edition). I had previously installed Python 3.5 64-bit from python.org (I'm using Windows 10). To start using PyCharm, I need a project interpreter, which I can select in the settings. As far as I'm concerned, the interpreter is "py.exe", but when I select it, I get this error message: "The selected file is not a valid home for Python SDK". I also tried to use every file whose name contained "python" or "py", and failed. On every website and video I see, they select a file called "python.exe", but they're using Python 3.4 or a previous version. I checked that PyCharm supports 3.5 ("Initial support for Python 3.5"). Is there anything I'm doing wrong? What should I do to be able to use PyCharm? All replies are appreciated. Thanks in advance.
PyCharm doesn't detect interpreter
1
0
0
53,023
32,832,755
2015-09-28T22:25:00.000
2
1
1
0
python-2.7,python-3.x
32,832,829
1
false
0
0
Learn Python 3 first. It's the future of Python and 2.x is in the rear-view mirror for most of the core developers. Learning Python 2.7.x won't be a waste of your time, as you'll often run into it "in the wild," but it takes years to gain mastery, so you might as well start on the path that will be the most relevant when you become fluent in the language.
1
0
0
I'm very new to programming, and have decided to start by learning Python; I've only been studying it for a little over a month, so I am very much still a beginner. Thus far, I really love the language, and am starting to grasp some of it. But that brings me to my question/concerns; because I am currently only trying to teach myself Python, most of any source that I find to teach myself, be it a book, videos or tutorials, are written for Python 2, and only occasionally for 3. So, is learning Python 2 going to make it more difficult for me, or slow me down? I really feel that I like the feel of Python 3 much more, but I am mostly learning 2. If I grasp the core concepts of Python in 2, will that translate into 3 easily? I just want to make sure that I won't regret having put much of my effort into 2, if it is going to make 3 more challenging. Thank you!
Is learning Python 2 along with 3 a waste of effort?
0.379949
0
0
106
32,834,722
2015-09-29T02:28:00.000
6
0
1
0
python,spyder
43,390,881
4
false
0
0
Just use combination of shift+ctrl+v
4
21
0
I accidentally closed the variable explorer on my Pythone(Spyder)... Does anyone know how I can reopen it? If I must reinstall the program, then I will but I just want to see if there is a way. Thank you!
spyder python how to re-open Variable Explorer
1
0
0
51,281
32,834,722
2015-09-29T02:28:00.000
2
0
1
0
python,spyder
59,318,950
4
false
0
0
You can go to view then in view click on window layout then in that click on reset to spyder default which will give you the default layout of spyder.
4
21
0
I accidentally closed the variable explorer on my Pythone(Spyder)... Does anyone know how I can reopen it? If I must reinstall the program, then I will but I just want to see if there is a way. Thank you!
spyder python how to re-open Variable Explorer
0.099668
0
0
51,281
32,834,722
2015-09-29T02:28:00.000
39
0
1
0
python,spyder
32,834,969
4
true
0
0
Go to View/Panes and select Variable Explorer.
4
21
0
I accidentally closed the variable explorer on my Pythone(Spyder)... Does anyone know how I can reopen it? If I must reinstall the program, then I will but I just want to see if there is a way. Thank you!
spyder python how to re-open Variable Explorer
1.2
0
0
51,281
32,834,722
2015-09-29T02:28:00.000
1
0
1
0
python,spyder
56,264,798
4
false
0
0
Just go to tools(look at the dashboard at top middle) and select reset spyder to factory dafaults and click ok You will get your default spyder console.
4
21
0
I accidentally closed the variable explorer on my Pythone(Spyder)... Does anyone know how I can reopen it? If I must reinstall the program, then I will but I just want to see if there is a way. Thank you!
spyder python how to re-open Variable Explorer
0.049958
0
0
51,281
32,836,510
2015-09-29T05:47:00.000
0
0
0
0
python,oracle,database-connection,cx-oracle
32,836,606
2
false
0
0
Yes, you definitely need to install an Oracle Client, it even says so in cx_oracle readme.txt. Another recommendation you can find there is installing an oracle instant client, which is the minimal installation needed to communicate with Oracle, and is the simplest to use. Other dependencies can usually be found in the readme.txt file, and should be the first place to look for these details.
1
1
0
I am writing a Python script to fetch and update some data on a remote oracle database from a Linux server. I would like to know how can I connect to remote oracle database from the server. Do I necessarily need to have an oracle client installed on my server or any connector can be used for the same? And also if I use cx_Oracle module in Python, is there any dependency that has to be fulfilled for making it work?
Python connection to Oracle database
0
1
0
6,425
32,847,487
2015-09-29T15:04:00.000
0
0
1
0
javascript,python,date,web,format
32,847,574
2
false
1
0
You can use Javascript to give the user the feedback that the correct format(s) is being used. But if you are taking any data to your server be sure verify the data on the server. To verify the correct dataformat you can use Regular expressions and check if any format is correct. You should iterate through all allowed possibilities until one is found correct.
1
0
0
I should preface this post by saying that I am a very elementary developer with a generic IS degree. Without going into too much detail, I was given a moderately large web application from an interning software engineer to support an enhance if need be. It was written primarily in Python, JavaScript and HTML5 and utilizes a Google Map API to visually represent the location and uses of given inputs. This leads me to my question. There is a date picker modal that the application/user utilizes. They pick a START and END date, in the default format YYYY-MM-DD (if the user does not use that exact format (i.e. 2015-09-29) the date picker will not work), and the application then goes to the DB and picks the given inputs between those dates and represents them on the map. I have been told that, for usability, I have to make the program accept multiple date formats (i.e. September 29 2015, 09-29-2015, 9-29-2015, 9/29/2015). How would I go about doing this?
javascript accepting multiple date format
0
0
1
163
32,849,325
2015-09-29T16:35:00.000
0
0
0
0
python,contextmenu,menuitem,maya,right-click
32,870,983
1
true
1
0
Okay i think I have found a solution, that's the best I have found but this is not very handy... create a copy of the buildobjectMenuItemsNow.mel and dagMenuProc.mel in your script folder so Maya will read those ones instead of the native ones. Once you have done that you can modify the dagMenuProc.mel without destructing anything as you re working on a copy. the proc that needs modifications is the last one : dagMenuProc (line 2240) and you can start modifying inside the loop (line 2266) What I have done is make a call to a Python file that adds some more items in the menu and you can obviously remove some items by deleting few MEL lines. I hope this can help someone. And if there is an other way of doing that, I would love to hear about !
1
0
0
I am trying to edit the right click context sensitive menu from Maya. I have found how to add a menuItem but I would like to have this Item in the top of the list not at the bottom... I think in this case I need to deleteAllItems from the menu, add mine and then re-add the default Maya ones but I don't know how to re-add them. Where can I find it ? Most of the topics say "modify Maya's source code" but that's not even an option. Any suggestions ? Thx !
Maya right click context sensitive menu
1.2
0
0
955
32,854,150
2015-09-29T21:34:00.000
0
0
1
1
python,macos,terminal
32,854,492
3
false
0
0
Also, if you just need to know which installation of Python is the system using, the way to do it is typing which python at the terminal.
1
1
0
I have several two python on my mac, one is original, and another is downloaded on the website, when I open the python in terminal, how can I decide which I'm opening? Thanks for help.
How can I decide which python I will open in mac terminal?
0
0
0
71
32,857,467
2015-09-30T03:50:00.000
1
0
1
0
python,regex
32,857,478
3
false
0
0
r"\bH[A-Za-z0-9]{9,19}\b" looks for precisely that.
1
0
0
Say I have a string "ldhjshjds HdAjhdshj4 Hdsshj4 kdskjdshjdsjds" I only want to search for substrings (alphanumeric only) starting with "H", but only if the string is between 10-20 characters. "HdAjhdshj4" would be a match. "Hdsshj4" would not. Would such a regex be costly on CPU cycles?
How to search for alphanumeric substring of specific length in Python?
0.066568
0
0
1,281
32,859,460
2015-09-30T06:41:00.000
0
0
1
0
python-2.7,machine-learning,scikit-learn,text-mining,text-classification
32,859,613
1
true
0
0
You can train individual classifiers for descriptions and merchants, and obtain a final score using score = w1 * predictions + w2 * components. The values of w1 and w2 should be obtained using cross validation. Alternatively, you can train a single multiclass classifier by combining the training dataset. You will now have 4 classes: Neither 'predictions' nor 'components' 'predictions' but not 'components' not 'predictions' but 'components' 'predictions' and 'components' And you can go ahead and train as usual.
1
0
1
I have text classification data with predictions depending on categories, 'descriptions' and 'components'. I could do the classification using bag of words in python with scikit on 'descriptions'. But I want to get predictions using both categories in bag of words with weights to individual feature sets x = descriptions + 2* components How should I proceed?
How to combine multiple feature sets in bag of words
1.2
0
0
713
32,860,932
2015-09-30T08:03:00.000
1
0
0
0
io,rethinkdb,rethinkdb-python
32,872,765
1
false
0
0
RethinkDB uses a blocker pool to do IO. On Linux systems, each thread in this blocker pool contributes 1 to the load average while blocking on disk, so RethinkDB sometimes causes the system to report an extremely high load average even under normal load. Using 100% of your disk throughput is a different story. If you're running an IO-heavy workload on a slow disk, especially on a rotating drive, then that's pretty reasonable, but it does mean that you might have scaling problems if you want to do more disk-intensive operations. If you start to have those scaling problems, probably the best solution would be to get a faster disk.
1
0
0
Rethinkdb IO reaches 100% whenever there is a data upload. The load reaches near about 50. Is this a common phenomenon, or do we need to do some optimizations here?
Rethinkdb IO reaches 100%
0.197375
0
1
86
32,863,132
2015-09-30T09:56:00.000
2
0
0
0
analytics,ironpython,spotfire
32,942,923
1
true
0
0
As @niko said, this is almost the same as your previous question. But basically you want show your data with 4 quarters in your bar chart. In that case, do not make 4 variables, but make 1 date variable and let spotfire do the splitting in quarters. This is a standard functionality in spotfire to create date hierarchies. On your category axis you can select the date and set this to quarters. Spotfire will then show all the quarters in your date. This also opens up the possibility to use the standard expression like year to date, difference, etc.
1
0
0
I need to use PG_Fiscal Quarter(Date(2015,10,1)) to make quarter 1. Similarly by putting four other starting dates in the fiscal quater I need four quarters in one bar graph. How can i have that. i cant simply assign them in custom expression
Displaying 4 custom expression in one graph
1.2
0
0
85
32,866,710
2015-09-30T12:56:00.000
5
0
1
0
python,pycharm
32,866,753
2
false
0
0
When you import the class, it imports it as-is at the current time. If you make changes after that, you need to import it again. In this case, you should just be able to terminate the shell, and start it again. This is not an error, or a bug.
1
3
0
I think this is a really silly / dumb question, but I am using PyCharm and constantly adding methods to a class or changing the body of the methods. When I test the class by importing the .py file and initiating the class object, it doesnt seem to recognize the changes to the class. Is there some button I need to hit to make sure that the class code is changed. The only thing that seems to work for me is to restart PyCharm.
PyCharm not recognizing new class method without reload
0.462117
0
0
1,172
32,869,355
2015-09-30T14:56:00.000
0
0
0
0
python,mesh,abaqus,orphan
33,103,479
1
false
0
0
In Abaqus you can only edit Native Meshes. This time, as you said, you have an Orphan Mesh. The only way to edit this kind of mesh is doing it by yourself with an external script.
1
0
1
I am trying to generate an orphan mesh on a part with python. I have already defined the nodes by using a code giving by Tim in another post. However, the with the following command: ListElem.append(myTrabPart.Element(nodes=tup,elemShape=HEX8) I ended up by the message "there is no mesh to edit". It seems that the ListElem is empty in my case. The list lengths are correct. Do you have any advice which could help me? Thanks, Romain
Generate orphan mesh in abaqus python
0
0
0
424