SublimeCodeIntel isn't looking in python 3 paths - python-3.x

I installed SublimeCodeIntel package in sublime text, and I use it to code in python 3. However, the problem is that it uses python2 paths to do the import, so if a library is installed in python2 and not in python3, i won't find it when i use import or from X import y.
I did confirm that when I used the command SublimeCodeIntel: Dump Import Directories , so I saw both the files python and python3 in the directory ./codeintel/import_dir_stats and here is there content :
python
dedeeb56f744e507026fef17243da41f /home/bilal/.local/lib/python2.7/site-packages
6a1d0cac3d9e6148e2208b63a33a1e6f /home/bilal/.local/lib/python2.7/site-packages/impacket
16a4fccbb3beadfdfd72691ef8f7298c /home/bilal/.local/lib/python2.7/site-packages/mechanize
211d2b55059f6b634799fdae534decd9 /usr/lib/python2.7/dist-packages
be5448890caffe81686310f127d6efae /usr/lib/python2.7/dist-packages/_markerlib
cec69a0830a725e10ac4e364d44add8f /usr/lib/python2.7/dist-packages/appindicator
python3
dedeeb56f744e507026fef17243da41f /home/bilal/.local/lib/python2.7/site-packages
6a1d0cac3d9e6148e2208b63a33a1e6f /home/bilal/.local/lib/python2.7/site-packages/impacket
16a4fccbb3beadfdfd72691ef8f7298c /home/bilal/.local/lib/python2.7/site-packages/mechanize
211d2b55059f6b634799fdae534decd9 /usr/lib/python2.7/dist-packages
be5448890caffe81686310f127d6efae /usr/lib/python2.7/dist-packages/_markerlib
cec69a0830a725e10ac4e364d44add8f /usr/lib/python2.7/dist-packages/appindicator
I didn't put all the lines (because there is a lot), but the content of the two files is identical.
I don't understand from where is coming this problem, why SublimeCodeIntel is looking in python2 directories for the import ??!!
PS : I am using Ubuntu 15.10 (with Linux version > 4), and sublime text 3 build 3103.
Please help, I really consumed a lot of time and energy looking for this.

I would strongly recommend using the Anaconda plugin (no relation whatsoever to the Anaconda Python distribution) instead of SublimeCodeIntel. I struggled with SCI for a while on various machines, and could never get very good code completion out of it until I ran across Anaconda one day. The next day I removed SCI and have been completely satisfied ever since. It's super-easy to configure (just give it the path to your python executable and it reads sys.path and all the rest), and pretty much just works. It has linting with several different linters built-in (you can disable them if you want), has popups available for function signatures and other hints, works with virtualenvs right out of the box, and more.
(I didn't write it and I have no connection to the author(s) - it's just a great plugin!)

Related

Converting .py to .exe with pandas imported for all users not having pandas

I'm new to Python, but I have set up an python script for searching some specific Values in 2 different excel sheets printing out matches (in excel).
Problem is, that our work machines are heavily locked down and without admin privileges, we can't really install anything (we can download though). Is there any version of Python that is Windows 7 compatible that will run standalone without requiring any sort of installer?
I have tried pyInstaller, but the problem is that in my script we need PANDAS.
And there is no possibility to pip install pandas to our local machines. All is blocked. ("pip install pandas" is not possible. I did the code with Anaconda)
So my question is: how can I set up a file for my coworkers, who have no permission to download pandas?
Can I set up an exe file (all use windows 7/10) in my private computer where pandas is already installed and forward it to the workers?
It should be very easy for them to use--> double click for executing the python script
Thanks in advance for any advice.
You can also use pyinstaller which personally I find the easiest to use. It can bundle executables for both Linux and Windows, but it must be run on that architecture that you wish to have executable for, i.e. if you want to have Linux executable the pyinstaller command with your code must be run on Linux OS of some kind.
More here: https://www.pyinstaller.org/
This is old so you may already have found a solution but this might help others.
Python by default is an interpreted language. This means that compiling it into an .exe file is impossible.
However, using some modules it is indeed possible to convert a .py script into a windows executable.
You can try py2exe.
py2exe is a Python Distutils extension which converts Python scripts
into executable Windows programs, able to run without requiring a
Python installation.
They have a tutorial here.

Pygame/Python/Terminal/Mac related

I'm a beginner, I have really hit a brick wall, and would greatly appreciate any advice someone more advanced can offer.
I have been having a number of extremely frustrating issues the past few days, which I have been round and round google trying to solve, tried all sorts of things to no avail.
Problem 1)
I can't import pygame in Idle with the error:
ModuleNotFoundError: No module named 'pygame' - even though it is definitely installed, as in terminal, if I ask pip3 to install pygame it says:
Requirement already satisfied: pygame in /usr/local/lib/python3.7/site-packages (1.9.4)
I think there may be a problem with several conflicting versions of python on my computer, as when i type sys.path in Idle (which by the way displays Python 3.7.2 ) the following are listed:
'/Users/myname/Documents', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python37.zip', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload', '/Users/myname/Library/Python/3.7/lib/python/site-packages', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages'
So am I right in thinking pygame is in the python3.7/sitepackages version, and this is why idle won't import it? I don't know I'm just trying to make sense of this. I have absoloutely no clue how to solve this,"re-set the path" or whatever. I don't even know how to find all of these versions of python as only one appears in my applications folder, the rest are elsewhere?
Problem 2)
Apparently there should be a python 2.7 system version installed on every mac system which is vital to the running of python regardless of the developing environment you use. Yet all of my versions of python seem to be in the library/downloaded versions. Does this mean my system version of python is gone? I have put the computer in recovery mode today and done a reinstall of the macOS mojave system today, so shouldn't any possible lost version of python 2.7 be back on the system now?
Problem 3)
When I go to terminal, frequently every command I type is 'not found'.
I have sometimes found a temporary solution is typing:
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
but the problems always return!
As I say I also did a system reinstall today but that has helped none!
Can anybody please help me with these queries? I am really at the end of my tether and quite lost, forgive my programming ignorance please. Many thanks.
Try it with the problem1
I'm not an expert neither, but I think you need to install both in terminal and python in order to use the program.
python -m pip install pygame
You should actually add the export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" to your .bash_profile (if you are using bash). Do this by opening your terminal, verifying that it says "bash" at the top. If it doesn't, you may have a .zprofile instead. Type ls -al and it will list all the invisible files. If you have .bash_profile listed, use that one. If you have .zprofile, use that.
Type nano .bash_profile to open and edit the profile and add the command to the end of it. This will permanently add the path to your profile after you restart the terminal.
Use ^X to exit nano and type Y to save your changes. Then you can check that it works when you try to run the program from IDLE.

cx_Freeze not found error-python

Ok, I am using python 3.4.3 and I think I downloaded the right file but when I go to python shell, it says No module named 'cx_Freeze'
I know there are plenty of questions like this but none of them helped. There was one I found using my exact same problem and version but even that did not work. I do not know what to do. I have put the file in the same place, I think anyways, as python is and I tried putting it on my desktop but still does not work. Any ideas?
faced a similar problem (Python 3.4 32-bit, on Windows 7 64-bit). After installation of cx_freeze, three files appeared in c:\Python34\Scripts:
cxfreeze
cxfreeze-postinstall
cxfreeze-quickstart
These files have no file extensions, but appear to be Python scripts. When you run python.exe cxfreeze-postinstall from the command prompt, two batch files are being created in the Python scripts directory:
cxfreeze.bat
cxfreeze-quickstart.bat
From that moment on, you should be able to run cx_freeze.
cx_freeze was installed using the provided win32 installer (cx_Freeze-4.3.3.win32-py3.4.exe). Installing it using pip gave exactly the same result.
Ok, I figured it out. So this is for all the future people have the same problem as I am. First, download pip. Then open a python shell and import pip. This is to make sure the download of pip was successful. Then go to the cx_Freeze website and for python 3.4.3, it will be the last one I think. It will say the version of cx_Freeze and then say the version of python which is 3.4.3 for me. That will download and then go to python shell and import cx_Freeze. It should work. Remember that you have to capitalize the "F" and have the code be exactly like this "cx_Freeze" but without the quotes. That is how I solved this problem with this exact python version.

Is there an installer for geodict python library?

I wanted to use the code:
import geodict_lib
locations = geodict_lib.find_locations_in_text(text)
But there seems to be no installer for geodict_lib. How do I install this is Anaconda 3.0 Python 3?
I know this is a year on, but perhaps I could help others who stumble on this. You'll need to place the files in the directory for modules that your installation of Python is monitoring.
First, download the .zip file from GitHub here.
Once you've done that, you can run the following at the command line or terminal:
conda list
This will provide the path to all installed packages in your installation of Python. Move the geodict.zip file you downloaded to that location. You might want to run which python as well (see here) since you may have a few different installations to check for.
Now when you run python import geodict in Python it should run without trouble!

Python using matplotlib and numpy

I want to share a Python3.3 tool, which for development convenience is split in variuos files/modules; these modules use tkinter, numpy-1.7.0rc1 and matplotlib-1.2.0.
My questions is:
is there a way to assemble these files/modules into a single self-standing executable file/script, freeing the not skilled user from installing tkinter, numpy and matplotlib, but only having the python3.3 interpreter installed (default in Ubuntu 13)?
You probably want to use a freezer like:
PyInstaller
cx_Freeze
Both are multi-platform (I do however only Windows, which should be the hardest target for freezing). Im my opinion PyInstaller is more complete/more actively developed in regard to packages with binary/data file dependencies but is rather non-standard if your own package contains data/binaries (write .spec files or hook files). cx_Freeze on the other hand is more standard (write a setup script based on setuptools).
As far as I experienced, both handle the nasty parts of matplotlib and its dependencies well and out of the box (pytz could be hairy on cx_Freeze).
include a python requirement file which contains the versions of the packages or the minimal version of it.
see https://pythonhosted.org/setuptools/setuptools.html

Resources