transcrypt issue - cannot run the sample program - transcrypt

Followed the instructions in transcrypt "getting started" docs, I entered the examples 'hello.html' and 'hello.py' in a separate directory.
Entering from the command line: "transcrypt -b -m hello.py" resuleds in the error message: "'transcrypt' is not recognized as an internal or external command,
operable program or batch file."
I'm using python3.6, with transcrypt installed in: C:\program files\python36\lib\site-packages\transcrypt
Any help to activate the sample hello.html would be appreciated.

Could you try python -m transcrypt -b -m hello.py
and tell me what the console output is?
Also: are you on Windows, Linux or OsX?
Answer: Windows 10
[EDIT 1]
Looks like Transcrypt was installed under a different Python distro. Would be good to know what's going on, so please keep us informed. I also have several Python installs on my Windows 10 computer and it can be confusing indeed.
[EDIT 2]
Another possibility is manual installation (although it isn't elegant...). From the docs
http://www.transcrypt.org/docs/html/installation_use.html#installation-troubleshooting-checklist
Alternatively, for manual installation under Windows or Linux, follow
the steps below:
Download the Transcrypt zip and unpack it anywhere you like
Add ../Transcrypt-/transcrypt to your system path
To enable minification, additionally the Java Runtime Environment 6 or later has to be installed
Note If you install Transcrypt manually, Trancrypt is started by typing run_transcrypt rather than transcrypt. This allows a pip
installed Transcrypt and a manually installed Transcrypt to be used
side by side selectively
BTW Thanks for the suggestion on Github. We'll look into it and try to improve the docs on this point. It seems to be quite difficult to really draw up a bullet proof installation procedure for each platform.

You might also find it easier to use python3's built in virtual env, so that you install Transcrypt and other python modules only into one project folder at a time. It's much easier to use than it at first sounds.
Here's how you might do that on Windows 10.
mkdir mynewproject
cd mynewproject
py -3 -m venv myvirtualenv # installs venv files into myvirtualenv
myvirtualenv\Scripts\activate # activates the virtual env
The py -3 command uses the python windows launcher to use the latest version of python 3. The launcher is defined in Pep 397 and the docs are here.
Once the virtual environment is activated, the prompt will change to show that. After which any 'pip install' commands will install packages into 'myvirtualenv', instead of the system wide location. If you want to deactivate it, just type 'deactivate' or close the shell window. You can also just use 'python' to refer to python3 from within the virtual env. This has saved many people from madness.

In case this helps for other newbies. A few problems I encountered when setting up transcrypt.
Path issues: I had multiple versions of python, in different folders: \python26, \python27, and \Program Files\python36.
This caused all sorts of grief, despite setting the environmental path to include the python36 distro. I fixed this issue by renaming the other versions \python26x and \python27x. This left those distros intact if ever I needed to use them, but stopped the system from finding them. Thus, it only found python36
My earlier suggestion of py -3 didn't really solve the multiple distro issue completely after all.
After doing that, I reinstalled transcrypt and it seemed OK (sort of: read on)
Second issue was trying to run the sample hello.py. I tried "transcrypt -b hello.py" and got a "'transcrypt' is not recognized.." message.
But this worked: python -m transcrypt -b -m hello.py
That worked because the system had finally found the correct version of python, due to the above fix.
Similarly, trying to run the sample hello.py as recommended in the docs caused a problem. run_transcrypt -b hello.py
The reason for this was that run_transcrypt resolved to "python $(dirname $0)/main.py $*"
But, because I had python v3.6 installed in c:\Program Files, the batch file run_transcrypt caused this output:
c:\transcrypt>python C:\Program Files\Python36\Lib\site-packages\transcrypt__main__.py -b hello.py
python: can't open file 'C:\Program': [Errno 2] No such file or directory
Consequently, I had to place Program Files in quotes and run it this way:
"C:\Program Files"\Python36\Lib\site-packages\transcrypt__main__.py -b hello.py
or else, as above: python -m transcrypt -b -m hello.py
I think, with respect, the docs should raise a warning flag here for users who have python installed in \Program Files, rather than, for example, in c:\python[x]
Third issue Changing hello.py to "play around" with the code -
I found the files in transcrypt\demos\ to be read-only. To fix this:
1: I opened the command prompt as administrator
2: I ran the attrib command to change the file attributes:
"c:\Program Files\Python36\Lib\site-packages\transcrypt\demos\hello>attrib -r -s -a hello.py"
(Without doing this as administrator you get an access-denied message)
The whole exercise caused a few hours of toing and froing, but it seems that things are better now.

Related

stupid nube cant even do one simple code test [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 10 months ago.
Improve this question
I decided recently that I want to start learning to code. I chose python as my first language because of it's versatility and Open Source connections. Now, of course to learn any programming language, first you have to be able to practice with it by writing code and running it.
I have Python beginner tutorials I am using but as soon as I got to the point where I wanted to run a simple Hello World message, I couldn't figure out how to get my document to actually RUN. I downloaded LiClipse with the hopes of using PyDev. I read that you can run a code directly from PyDev.
Wow, what a confusing mess! I downloaded the instant install version of LiClipse and I had to manually update the pip because it was out of date and that took an hour of research all on it's own to figure out how to do it.
Now that I have the interpreter set up correctly with the most recent pip...(I THINK), when I try to run any code I write, it doesn't let me. It wants me to save it first, which of course is quite logical. But when I try to save it, it says there is no folders to save to. How can there be no folders? I have been reading the install help, but it doesn't say anything about this issue. Or maybe it did explain how to fix this issue and I simply didn't understand all the jargon included in the configuration documentation. It kept instructing me to do technical things I couldn't understand.
Can anyone tell me what is going on? Shouldn't this all be ready to go when I used the "instant install" ?? I am just a beginner here, I don't know all this technical installation jargon. If anyone can help me get this setup, please let me know.
I really want to start learning. But I can't if I don't have the right tools.
Yeah, the technical jargon can be really confusing in the beginning. I've never heard of LiClipse but I can give you a few tips to get started:
Use a good IDE or Editor. For beginning VsCode with the Python PlugIn is quite good. You can also use PyCharm (the free version is enough) but that IDE is quite confusing.
Get comfortable with the commandline. On Windows you can invoke Python by running py on Linux with python3. You open the commandline on Windows by opening the startmenu, entering cmd and hitting enter.
You will have to make sure Python is in your "PATH" enviroment variable. That is a variable telling the Operating System where to find your programms. It should have asked you whether you want to add Python to your PATH during the install.
You run your python programm by saving it as a .py file and running py <filename.py> or python3 <filename.py> on Windows or linux respectively. You have to be in the directory where you saved your file of course.
I hope I could help you. Please mark this answer as accepted if it did answer your question or helped you with your issue.
I want to start by saying I'm mainly experienced in C & C++, not Python, but with programming in general many of the concepts carry over. I also don't have enough rep to comment, or I'd ask for some clarification on how familiar you are with the commandline.
I'm going to assume you're on Windows since you didn't mention the platform.
I wrote this like a tutorial, because I found those to be very helpful when I first started programming.
I can't recommend this enough, start off by using the commandline!
I think you complicated things more by searching for a text editor that can also run code. In order to get something like that working for your setup you need to know what's happening behind-the-scenes first.
Once you have a grasp of how to write & execute Python code, then you can move on to an IDE or advanced text editor like Visual Studio Code or LiClipse with confidence.
R+Click on the Start Menu, then click on Windows PowerShell to open a terminal.
Take a moment to note the filepath shown before the blinking cursor.
This is known as the Working Directory, which works similar to how the file explorer only allows you to "view" one directory at any given time; You can open multiple explorer windows side-by-side, but you can't view multiple directories at the same time in a single window.
You can run commands by typing them and pressing Enter.
You can also use the Tab key to autocomplete things like directory/file names, commands, etc. after typing a few characters.
Now let's create a workspace directory for your first project.
This can be anywhere that you choose, but for the sake of simplicity I'll be using my User directory which is usually where PowerShell will start by default.
To create a new directory named _workspace, use the mkdir (Make Directory) command like so:
mkdir _workspace
Now let's change our working directory to _workspace by using the cd (Change Directory) command like so:
cd _workspace
This directory is empty, but if you want to view the contents of a directory you can use the ls (List Directory) command:
ls
Since this is an empty directory, nothing will happen.
Next, we'll create a Python script file using the touch command, which creates empty files:
touch HelloWorld.py
Now that we have a script file, open HelloWorld.py in Notepad by running this command:
notepad HelloWorld.py
If you use a dark desktop theme, now is the time when your retinas may be seared out by the intensity of Notepad's white color scheme.
Now, let's add the code to print "Hello World!" in Python:
print("Hello World!")
Once you're done, you can save & close Notepad to save your retinas.
Now it's time to run the program! In the PowerShell window, enter this command:
py HelloWorld.py
which will show:
Hello World!
If you see an error saying this:
The term 'py' is not recognized as the name of a cmdlet, function, script file, or operable program.
You should re-install Python and make sure you check this box in the installer:
After re-installing Python and checking the Add to PATH box, close and reopen the PowerShell window, enter the cd _workspace command again, followed by py HelloWorld.py, which should be successful this time.
I hope I could be of some help, if so, I'd greatly appreciate marking this answer as accepted so I can write comments. Happy coding!
If you are using Linux following will work.
Install python3 first (Its better to stuck on python3 now. Once you get use-to then you can code in python2.7 also.)
Open a terminal, go the folder contains your code. If your source code is in hello.py then type python3 hello.py on terminal. It will execute and print the output on terminal.
The suggestions given by both #radj and #C. Dautermann are excellent.
Like others here, I will be assuming that you are on Windows.
Before jumping into LiClipse and PyDev, I highly recommend making sure that Python and packages (such as pip) are functioning on their own first. Command line is a great tool for this.
Windows Command Line can be accessed in a variety of ways, one of which is to go to your start menu and search "cmd." Command Prompt should return. In the command prompt, run the following:
python
This should return the version of Python installed on your machine if it is configured properly. For example, you may see the following:
Python 3.10.1 (...)[...] on win32
If this does not appear, I recommend uninstalling Python and reinstalling. In the installer, you will want to check the "Add Python ... to PATH" option. This will configure your environment variables on your machine. If you plan on running multiple versions of Python down the road, don't worry; you can use batch files to set the PATH variable to another version.
Once you have Python working, your command prompt will lead with the following:
>>>
Notice that there is no longer a file path followed by >>. This is because you are now in the Python interpreter. Congratulations!
To exit the Python interpreter, enter Ctrl+Z. It should appear as the following:
^Z
After we know Python works, we will check to see that pip works. Ensure you have pip installed by entering the following:
python -m pip --version
You should then be able to see the pip version. For example:
pip 22.0.3 from C:\...
If pip is not working, you can consult this documentation on pip to make sure pip gets installed properly.
Once pip is working, again, congratulations! You've gotten over some of the biggest hurdles. At this point, you can open up any text editor, type in:
print('Hello World!')
save the file with the extension .py, then run the script through command prompt. To run a script through the command line, you have to cd to the file location, then run the script with python, like so:
cd filepath
python filename.py
Where filepath is the path to the Python file and filename is the name of the file. For example:
cd C:\Users\name\Documents\PythonPractice
python helloworld.py
Usually, command line is all that is needed when starting out with Python outside of a text editor. Notepad comes standard on Windows computers, but there are plenty of other editors out there. Sublime text and Notepad++ are some of my favorites, personally.
Now, if you're able to run everything prior, the good news is that your Python and pip are both working, and you have everything you need to get started learning Python. If Python and/or pip are not functioning, there's thankfully a huge body of troubleshooting tips out there.
Unfortunately, from what I get of your initial post, you might be struggling with configuring LiClipse. I personally do not use LiClipse, nor do I use PyDev, so my help at this point may be limited. You may want to uninstall and reinstall after confirming your Python and pip work as a first step. After that, perhaps check that you are following the practices outlined in the LiClipse manual. Worst case scenario, you can try a different version of Python (I believe it has some Python3 incompatibilities), try running PyDev independent of LiClipse, or look at a different tool. If you believe the problem lies with file locations/existence, I would look at radj's post or play around in File Explorer to see what is going on for yourself.
Again, to get familiar with Python, you don't even need these extra tools. All you need is a text editor and the command line to get started.
Some other tools to help you get started:
PyPI
A venv virtual environment tutorial
PyDev
A comparison of LiClipse alternatives in case you continue to struggle
Hope this helps. Happy Coding!

Cannot run git clone or pip install commands

So i'm pretty new to the whole windows repo cloning thing. I installed python 2.7, added the path to my windows cmd and I still cannot run any git clone commands. It shows the following output :
git clone
File "", line 1
git clone
^
I've been scouring the internet for an answer but apparently it should work if I use cmd.
Any help would be appreciated!
git clone
File "", line 1
git clone
^
I have had the same issue recently with 3.7, so I made a new username and it worked. Kind of nice, a clean new Windows profile, even though I just started using it again compared to linux. A pain though.
Make sure all other versions of Python are not installed, or at least affecting the path to the file you need the pip installs to be saved. Python can be saved in a few different locations, and some rare times it has been shown in very obscure places. Check where your file saved on your PC. Probablu C:/ then could be many paths. /Users/UnserNameHere/Windows/ProgramFiles. I would use the search bar in the good old GUI while searching under the C drive (if you have multiple HDD/SDD then pic the one used for the C drive, if nothing comes up try the other drives.
Your looking for a file PythonFoundation I can't remember the entire name, however it will have a very long name Python Foundation are in the name of the file. This is where thing are store and where the path should be sending modules, at least the correct file inside that file.
Also try doing it from other Python versions installed. If you had 3.6 and got 3.7 it doesn't mean 3.6 has been deleted. Also doesn't mean you path, is not set to 3.6 while using 3.7. Same with Python 2, most people or many have both. The pip commands vary between python versions pip3 I believe is used (getting windows and linux a little mixed up right now)
If all fails do it the old fashon way, find the mod, download it, and move it to the python file I mentioned above. The homepage for python should have a tab linking to a page, or it's on the main page, letting you know where it has been known to save. Google how to see he path Pip is taking, or how to see if pip is installed and where, and what paths are set to.

Error trying to rebase msys-2.0.dll:

Using Cygwin on Windows 7 64 bit.
Trying to rebase msys-2.0.dll: for Git with the below command.
However I am getting the message saying its skipped because its wrong machine type.
cd /cygdrive/c/Program Files (x86)/Git/bin
$ rebase.exe -b 0x50000000 /cygdrive/c/"Program Files (x86)"/Git/bin/msys-2.0.dll
/cygdrive/c/Program Files (x86)/Git/bin/msys-2.0.dll: skipped because wrong machine type.
What does this mean? Trying to look up on Google but didn't find much information anywhere - so hoping someone in this community can help.
As mentioned here, it could be a Cygwin issue depending on your current version of Cygwin.
But you can also try the alternative without cygwin, using the latest git-for-windows:
unzip PortableGit-2.6.3-64-bit.7z.exe anywhere you want
add to your %PATH% the folders C:\path\to\PortableGit-2.6.3-64-bit\bin and C:\path\to\PortableGit-2.6.3-64-bit\usr\bin (that last path comes with 200+ Linux gnu commands: ls, xargs, awk,... all accessible from your CMD.exe session!)
Then try again your git commands.

Full installation instruction of youtube-dl in windows

I have just downloaded the youtube-dl-2014.07.15.tar_2.gz in my windows. At first I want to tell I don't know anything about python. And I already have installed python 2.7. Can anyone give me instruction to execute these scripts?
I have already tried to run...but there is some error like these. "No mudule named youtube-dl"
I want a fresh start. Now I am using windows 8.1 and I have also tried youtube-dl.exe. And there is also problem like screenshot
If I want to get worked both script and program what will I do?Any helps will be appreciated. If you give me instruction from scratch that will be better.
To install youtube_dl in Python on Windows (command from their github):
Tested with Python 3.9 on Windows 10
pip install --upgrade youtube-dl
Now when using it, notice that the name of the Python module is with an underscore.
Because it is a Python module, use it like so:
py -m youtube_dl <video url>
Of course video url is the video you want to download
This seems to be caused by a limitation of py2exe. You may want to file a youtube-dl bug report for moving to a cxfreeze, which should not have that problem. In any case, simply moving the youtube-dl.exe file into another directory such as C:\Users\Shamim should fix the problem.
you need just to put the youtube-dl.exe file in in your home directory or any other location on your PATH.
You can see your PATH in your "Envirenment Variables"

What files did `make install` copy, and where?

Is there a way to get a list of filenames/paths that make install copies to the filesystem? Some packages come with a MANIFEST file, but not the ones that I am working with.
I was just investigating this myself while compiling a custom version of QEMU. I used the following method to work out what was installed and where (as well as using it as a basis for a .deb file):
mkdir /tmp/installer
./configure --target-list=i386-softmmu
make
sudo make install DESTDIR=/tmp/installer
cd /tmp/installer
tree .
Tree is a utility that recursively displays the contents of a directory in a visually appealing manner - sudo apt-get install tree for Debian / Ubuntu users
Hope that helps someone... it took me a bit of poking around to nut it out, but I found it quite a useful way of visualising what was going on.
The most fool-proof way is to use chroot: have "make install" run inside a chroot jail; compute a list of the files that you had before the installation, and compare that to the list of files after the installation.
Many installations will support either a --prefix configuration option, and/or a DESTDIR environment variable. You can use those for a lighter-wait version of chroot (trusting that the installation will fail if it tries to write to a location outside these if you run installation as a fairly unprivileged user).
Another approach is to replace the install program. Many packages support an INSTALL environment variable that, well, is the install program to use; there are tracing versions of install around.
make uninstall might show the files as it removes them if the author of the compiling instructions provides the information to allow an uninstall (it has been awhile since I have done one so I can't say for sure).
Also make -n install will do a "dry run" of the install process and it may be reasonable to extract the information from its results.
It differs for every project that you run 'make install' on. The files which are installed are controlled by the install target in the Makefile being used. Your best bet is to open the Makefile and search for 'install:' - from there you can see what files will be copied out to your system.
Take a snapshot of the contents of the install location before installing
Install
Compare the current contents with the old contents.
Example:
./configure --prefix /usr/local
make -j`nproc`
find /usr/local | sort -u > /tmp/snapshot1
make install
find /usr/local | sort -u > /tmp/snapshot2
comm -3 /tmp/snapshot{1,2} # this prints the files added by `make install` to stdout
If the install program you're using doesn't support DESTDIR or --prefix (or an equivalent), I have found that it may be possible to identify new files as follows:
Start with as clean a system as possible (a fresh VM image is preferable)
Compile the software, wait a few minutes.
Install the software package.
Find files modified within the past 5 minutes: sudo find / -mmin -5 -type f (the find command has a ton of parameters for querying based on file modification / creation times, but this worked pretty well for me; you just need to narrow the time span so that you pick up the files created by the installer but nothing else).

Resources