How to set up gitpython on in Visual Studio Code so it is setup once - macos

I am developing on OS/X using Visual Studio Code (1.30.1). My script works but each time I close and re-open Visual Studi Code, I have to setup GitPython again. I want to set it up once and have it work.
I am developing with GitPython which I set up as follows via the VS Code Terminal window:
python3 -m venv gitpy
source gitpy/bin/activate
pip install gitpython==2.1.11
The python file, anyfile.py, is simple (the only line that matters is as follows):
from urllib.parse import quote
If I close and re-open the code, I cannot run the script:
python anyfile.py
The error is as follows:
Traceback (most recent call last):
File "anyfile.py", line 1, in
from urllib.parse import quote
ImportError: No module named parse
I can fix the issue by running the following from the Visual Studio Code Terminal window:
source gitpy/bin/activate
pip install gitpython==2.1.11
What am I doing wrong? Thanks in advance.

Related

Visual Studio Code ModuleNotFoundError: No Module Named Seaborn

can you help me out with this
I'm trying to import seaborn as sns
but on my screen, it just showed
Traceback (most recent call last):
File "", line 1, in
ModuleNotFoundError: No module named 'seaborn'
I tried to uninstall then re-installed seaborn on anaconda so many times but it doesn't work
Thank you for your help
Please, check if, in VSCode, you are using the Python environment in which you installed Seaborn. Refer to this post. You may be using a Python environment that is not from Anaconda.
You may also try to install the package via VSCode, using the normal conda or pip commands as they tell here. In this case, the package is installed in the environment in use.

Unable to run Autokey Ubuntu 18.04

I am relatively new to Linux/Ubuntu (so please take it easy on me) and I am trying to install Autokey to use the text expansion functionality. I have tried installing it from the instructions on the Github page here - https://github.com/autokey/autokey#installation
However, no matter whether I follow the installation process under the Ubuntu/Mint/Debian section or the instructions to install via pip I cannot seem to get the program working.
The installation seems to be successful (running a 'which' command gives the path installed) but clicking on the icon does not launch the program.
I have also tried to install directly from Ubuntu/GNOME software manager but that also will not launch the program once installed.
I have tried installing both the GTK and QT frontends and neither will launch. I don't get an error message or anything. I have opened up the System Monitor to see if a process even appears (however briefly) and there's nothing.
Typing autokey-gtk into Terminal gives:
/usr/local/lib/python2.7/dist-packages/autokey/gtkapp.py:24: PyGIWarning: Gtk was imported without specifying a version first. Use gi.require_version('Gtk', '3.0') before import to ensure that the right version gets loaded.
from gi.repository import Gtk, Gdk, GObject, GLib
Traceback (most recent call last):
File "/usr/local/bin/autokey-gtk", line 20, in <module>
from autokey.gtkapp import Application
File "/usr/local/lib/python2.7/dist-packages/autokey/gtkapp.py", line 28, in <module>
import service, monitor
File "/usr/local/lib/python2.7/dist-packages/autokey/service.py", line 21, in <module>
from iomediator import Key, IoMediator
File "/usr/local/lib/python2.7/dist-packages/autokey/iomediator.py", line 107, in <module>
from interface import *
File "/usr/local/lib/python2.7/dist-packages/autokey/interface.py", line 29, in <module>
from Xlib import X, XK, display, error
ImportError: No module named Xlib
Can anyone please help? Thank you.
I am a newbie too and installed Autokey 0.90.4, which did not work for me either. Someone suggested I try 0.95.1 because the other version is 7 years old.
I installed the new version with some acrobatics from the Autokey Github page, using the PIP method. At 1st it did not work, but after doing import setuptools it did. That might be a coincidence since it was after installation of the Ak package itself.
I know this sounds convoluted, but I am not familiar (yet?) with Linux. Anyway 0.95 works for me.
install module python-xlib and it will work, like this:
On Deb:
apt install python3-xlib
You might later need python autokey module as well:
pip install autokey

Using pip 10.0.1 to install modules

lately using 9.0.1, I have been using Project Interpreter to import modules for my files. I opened up a new project in PyCharm today to try and test 10.0.1. Using the Pip version of 10.0.1, I couldn't install packages into my file.
The command output was :
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm Community Edition 2017.3.3\helpers\packaging_tool.py", line 192, in main
retcode = do_install(pkgs)
File "C:\Program Files\JetBrains\PyCharm Community Edition 2017.3.3\helpers\packaging_tool.py", line 109, in do_install
return pip.main(['install'] + pkgs)
AttributeError: module 'pip' has no attribute 'main'
I googled this and it said that installing modules through pip was now unsupported, especially for
pip._internal.main
After looking at this site : https://pip.pypa.io/en/latest/user_guide/#using-pip-from-your-program for a while, it says to use :
subprocess.check_call([sys.executable, '-m', 'pip', 'install', 'my_package'])
I tried executing it and command prompt said that subprocess.check_call is not an internal or external file.
i also tried executing the commands through Command Prompt and downgrading my pip to 9.0.1 but none of this worked. When I changed Pip to 9.0.1 in Command Prompt, it had no effect on PyCharm.
Can anyone help with trying to import modules into PyCharm because I am currently trying to make a webcrawler using modules beautifulsoup4 and it is not letting me import it.

cannot run scons - unable to find files

So I've installed scons via Anaconda's conda install scons under Windows 10 (Python 3.6) and could not execute it via the command line so I've added C:\Users\D\Anaconda3\envs\py36\Scripts\ to my Path (even tough C:\Users\Dominik\Anaconda3 was already in there).
Now I can execute it in the Powershell, but I get an error, because it is unable find engine files:
scons
SCons import failed. Unable to find engine files in:
C:\Users\D\Anaconda3\envs\py36\Scripts\..\engine
C:\Users\D\Anaconda3\envs\py36\Scripts\scons-local-3.0.1
C:\Users\D\Anaconda3\envs\py36\Scripts\scons-local
C:\Users\D\Anaconda3\scons-3.0.1
C:\Users\D\Anaconda3\Lib\site-packages\scons-3.0.1
C:\Users\D\Anaconda3\scons
C:\Users\D\Anaconda3\Lib\site-packages\scons
Traceback (most recent call last):
File "C:\Users\D\Anaconda3\envs\py36\Scripts\scons.py", line 192, in <module>
import SCons.Script
ImportError: No module named 'SCons'
Does someone know how to further investigate/fix this problem?
I found it thanks to nekomatic.
If you use the anaconda prompt (with the correct environment activated or in my case the correct shortcut leading to anaconda prompt in that environment), scons runs just fine.
See this link explaining how anaconda uses the path on windows and whats the advantage of using the anaconda prompt (mainly it dynamically manages PATH correctly for that session only with full knowledge of conda environments).

Why does IronPython tell me that pip is a package and not an executable?

I am a complete newbie at Python. I wanted to try to see if Pyomo (a Python package for mathematical modeling) could work under IronPython because all my code for generating the data needed for Pyomo is in C#.
I installed IronPython 2.7.5, then tried as an administrator the advice found in http://blog.ironpython.net/2014/12/pip-in-ironpython-275.html#disqus_thread on how to run "pip" for IronPython. I used the exact example they gave (installing html5lib):
ipy -X:Frames -m ensure pip
ipy -X:Frames -m pip install html5lib
The first line worked, and I see in the Lib/site-packages directory a folder called pip-6.1.1-py2.7.egg with lots of python code in it.
For the second line, I received the error:
Unhandled exception:
Traceback (most recent call last):
File "C:\Program Files (x86)\IronPython 2.7\Lib\runpy.py", line 170, in run_module
File "C:\Program Files (x86)\IronPython 2.7\Lib\runpy.py", line 111, in _get_module_details
ImportError: No module named urllib; 'pip' is a package and cannot be directly executed
At this point, I'm stuck. Any help would be appreciated.
Just in case this helps, printing out the sys.version gives:
2.7.5 (IronPython 2.7.5 (2.7.5.0) on .NET 4.0.30319.34209 (32-bit))
I encountered the same problem. It seems that IronPython can't deal with more recent versions of pip. What I did was:
remove all traces from pip and setuptools from IronPython's Lib\site-packages folder
run from a commandline: ipy.exe -X:Frames -m ensurepip
this installed an old version of pip, one that IronPython understands. Verify this by checking that a folder pip-1.5.6.dist-info appears in IronPython's Lib/site-packages
Moral of the story; don't upgrade to a newer pip version when using IronPython

Resources