Jython 2.5 and virtualenv on windows - windows

I have installed Jython 2.5 on Windows, then setuptools and finally virtualenv (1.8.4) using easy_install. Now I am trying to create a new virtual environment using the following command line :
jython \Lib\site-packages\virtualenv-1.8.4-py2.5.egg\virtualenv.py jython_env
But the creation of the new virtual environment fails with the following error:
os.symlink(py_executable_base, full_pth)
AttributeError: 'module' object has no attribute 'symlink'
I guess this is because Windows does not handle symlinks but does anyone already meet this issue, is there any workaround ?
Thanks

A little bit late, but for the benefit of others who may read this page...
I recently encountered the same issue with jython2.7.0 and managed to get around this by hacking jython's Lib/os.py (mine was under C:\jython2.7.0) to add at the bottom:
def symlink(target, file):
''' Just copy files in Windows,
maybe you could use mklink system calls instead '''
from shutil import copy
copy(file, target)
Don't forget to remove the compiled bytecode version of the os module otherwise the changes won't be loaded.
Then try running virtualenv -p /path/to/jython.exe jython-env-name.
Note that you should either have python2*.dll from your jython bin/ directory in your system PATH , have the dll registered or else copy the dll into your new virtualenv's bin directory.

Related

Installing Meson from pip results in missing meson.py

I am having a similar issue to this problem.
I want to download Meson for Windows and used the following command:
pip3 install meson
This installs in my site-packages folder, specifically c:\users\user\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages\mesonbuild
However, running meson or python3 meson.py results in an error:
'meson' is not recognized as an internal or external command, operable
program or batch file.
When looking at the mesonbuild directory within site-packages, I seem to be missing the meson or meson.py file. Has anybody ever come across this issue before?
After opening up Visual Studio, and looking at the installed Python packages in my environment, I noticed this interesting information window above the list of my Python packages:
Due to new security restrictions, installing from the internet may not
work on this version of Python.
After seeing this, I decided to install Meson through the website's MSI installer. Indeed, after trying to download the installer, Windows threw up all kinds of security warnings and "are you sure you want to do this" notifications before I convinced Windows that I really did want to install Meson.
I just wanted to share this with anybody that might have the same issues. The MSI installer worked for my needs.
Try the following :
python3 -m mesonbuild.mesonmain build
Meson pip package contains meson and mesonbuild modules. The meson module serves as Python entry point, which, during an initial execution of setup.py, associates mesonbuild.mesonmain:main with command line name 'meson'. (Explain Python entry points?). To invoke meson via python3 use python3 -m mesonbuild.mesonmain build, which writes build config into 'build' directory (provided that there is meson.build file in the current directory.) There is no such file 'meson.py' in mesonbuild module and meson module does not contain any Python code.

comtypes.gen attributes are different from self download and conda pre-installation

I have created my own Anaconda environment. I needed to use the 'comtypes' package to connect to the software ETABS, so I first downloaded it with the conda installation command and then I tried the next command line:
helper = comtypes.client.CreateObject('ETABSv17.Helper')
But, I received the next error:
AttributeError: module 'comtypes.gen.ETABSv17' has no attribute 'cHelper'
However, I realized that if a try the same command line with the base environment coming with Anaconda, that includes a pre-installed 'comtypes' package, there is no problem. In fact, if I check comtypes.gen.ETABSv17 with my customized environment and with the one from Conda, there is a huge difference between available attributes, even when they have the same version number: comtypes 1.1.7.
How can I get the exactly same 'comtypes' package that comes with Anaconda in order to have all the associated attributes working? Maybe, could there be some package dependence that I am missing?
Pd: I am using Windows10 and I have tried it in Pycharm and Spyder with Python 3.7
Thank you all !
I had this issue and i was using python 32 bit version. So uninstalled and installed a 64 bit version and now its working fine. May be this helps

Biopython, import error with "import Bio"

I have installed Biopython by Anaconda on Windows.
When I try import Bio I get this error:
ModuleNotFoundError: No module named 'Bio'
Why?
Simone.. it looks like your installation did go wrong somehow. Regardless of why and how try the following stepwise approach to see if your import error remains.
On Windows (the dots denote your installed program path specifics):
e.g. go to: C:\....\Anaconda...\Lib\site-packages
find and remove folders using delete.
folder 1: "\Bio"
folder 2: "\biopython-1.70.dist-info"
The version value 1.70 might be 1.69 when using conda for installation.
Empty your trashbin. This way the system can't do tricks and recover or link to deleted files and folders.
Install pip if its not and grab it from here.
try pip install biopython --no-cache-dir
Voila! Hope it works now for you too... Enjoy!
In case its not check windows environment variables\path.. via control panel>advanced system settings to include PATH to site-packages. Or do similar on other OS.

Installing File::MMagic using CPAN but can't be found in #INC

I've tried installing File::MMagic in CPAN using
install File::MMagic
in CPAN.
When I try to call my script and associated variable (which uses File::MMagic) it fails telling me that File/MMagic.pm can't be found in #INC. Unsure how to proceed, all suggestions welcome! I'm on Mac OS Sierra
So I solved this. The answer could be found in the error message. When it installs File::MMagic the directory structure it creates doesn't include a File directory. The script is trying to call File/MMagic.pm. By creating a new directory and calling it File and putting MMagic.pm in there it ran successfully.

Why is pydot unable to find GraphViz's executables in Windows 8?

I have GraphViz 2.32 installed in Windows 8 and have added C:\Program Files (x86)\Graphviz2.32\bin to the System PATH variable. Still pydot is unable to find its executables.
Traceback (most recent call last):
File "<pyshell#26>", line 1, in <module>
graph.write_png('example1_graph.png')
File "build\bdist.win32\egg\pydot.py", line 1809, in <lambda>
lambda path, f=frmt, prog=self.prog : self.write(path, format=f, prog=prog))
File "build\bdist.win32\egg\pydot.py", line 1911, in write
dot_fd.write(self.create(prog, format))
File "build\bdist.win32\egg\pydot.py", line 1953, in create
'GraphViz\'s executables not found' )
InvocationException: GraphViz's executables not found
I found this https://code.google.com/p/pydot/issues/detail?id=65 but am unable to get the problem solved.
The problem is that the path to GraphViz was not found by the pydot module as shown in the traceback:
'GraphViz\'s executables not found'
I solved this problem on my windows 7 machine by adding the GraphViz bin directory to my computer's PATH. Then restarting my python IDE to use the updated path.
Install GraphViz if you haven't already (I used the MSI download)
Get the path for gvedit.exe (for me it was "C:\Program Files
(x86)\Graphviz2.34\bin\")
Add this path to the computer's PATH
One way to get to environment settings to set your path is to click on each of these button/menu options: start->computer->system
properties->advanced settings->environment variables
Click Edit User path
Add this string to the end of your Variable value list (including
semicolon): ;C:\Program Files (x86)\Graphviz2.34\bin
Click OK
Restart your Python IDE
On Mac brew install graphviz solved the problem for me.
This happened because I had installed graphviz after I had installed pydot. Hence, pydot wasn't able to find it. Reinstalling it in the correct order solved the problem.
I tried adding PATH via Control Panel, but restarting the command prompt is also needed. The following also works for updating the path in a Notebook session without exiting:
import os
os.environ["PATH"] += os.pathsep + 'C:/Program Files (x86)/Graphviz2.38/bin/'
in my case answer from Sadik
pydot and graphviz error: Couldn't import dot_parser, loading of dot files will not be possible worked for me on Ubuntu 12.04.5 LTS
sudo apt-get install python-pydot
You need to install from Graphviz and then just add the path of folder where you installed Graphviz and its bin directory to system environments path.
For windows 8.1 & python 2.7 , I fixed the problem by following below steps
1 . Download and install graphviz-2.38.msi https://graphviz.gitlab.io/_pages/Download/Download_windows.html
2 . Set the path variable
Control Panel > System and Security > System > Advanced System Settings > Environment Variables > Path > Edit
add 'C:\Program Files (x86)\Graphviz2.38\bin'
Restart your currently running application that requires the path
I'm working on Windows 10 with Anaconda 3.6.5. I have not admin rights, so if someone is under the circumstances like me this solution works perfectly.
The path for my graphviz is looks
C:\Users\User_Name\AppData\Local\Continuum\anaconda3\Library\bin\graphviz
In Spyder or in Jupyter type the following:
import os
os.environ['PATH'].split(os.pathsep)
This will lists all the path in you environment. Take a look to them, if your graphviz path is not here, then go find it and copy the path, like above in my example.
Then type the following:
os.environ['PATH'] += os.pathsep + 'C:\\Users\\User_Name\\AppData\\Local\\Continuum\\anaconda3\\Library\\bin\\graphviz'
That's all, but note that you have to run these command every time if you restart kernel
Add dot.exe to your path.
right click my computer > advanced system settings > environment variables > high light 'path' > edit
then append everything in the quotes to path ";C:\Program Files (x86)\Graphviz2.34\bin\" depending on where you installed Graphviz ofcourse.Then restart the python shell and type.
import pydot
pydot.find_graphviz()
Make sure there is a slash after 'bin' so it gets everything from inside the folder, I tried with out the slash and the above code returned nothing, however after adding the slash it returned the graphviz executables it needed and their paths.
For me: (Win10, Anaconda3)
Make sure you have done "conda install graphviz"
I have to add to the PATH: C:\Users\username\Anaconda3\Library\bin\graphviz
To modify PATH go to Control Panel > System and Security > System > Advanced System Settings > Environment Variables > Path > Edit > New
MAKE SURE TO RESTART YOUR IDE AFTER THIS.
It should work
In Windows, even after installing graphviz-2.38.msi, you can add your own path in pydot.py (found under site-package folder)
if os.sys.platform == 'win32':
# Try and work out the equivalent of "C:\Program Files" on this
# machine (might be on drive D:, or in a different language)
#
if os.environ.has_key('PROGRAMFILES'):
# Note, we could also use the win32api to get this
# information, but win32api may not be installed.
path = os.path.join(os.environ['PROGRAMFILES'], 'ATT', 'GraphViz', 'bin')
else:
#Just in case, try the default...
path = r"C:\PYTHON27\GraphViz\bin" # add here.
I too had the same issue and I finally resolved it by having a look at the library.
The library considers making the path set as C:\Program Files\ATT\Graphviz\bin but by default Graphviz is installed to C:\Program Files(x86)\Graphviz undergoing the 32-bit criteria hence the pydot fails in getting the required path.
Simply shift the directory as required by the script and you're good to go.
P.S.:- Consider making the equivalent changes to the Environmnet Variable.
P.S.S:- Also check if Graphviz is directly under Program Files(x86) or under ATT.
I am running a Windows 10 machine and had some problems, too.
I installed graphviz via msi installer. Adding via System settings did not work for me.
I removed the installation with the msi and used chocolatey, a windows package manager.
Removing the installed version is necessary, otherwise chocolatey won't install.
Now it runs fine. I would recommend doing it this way.
Here is what I did for the above mentioned problem. I'm using windows 10 os and python 3.6.5
Install PIP by clicking here
open command prompt and type command "pip install graphviz"
go to my computer(this pc) and search with the keyword "graphviz"
open the graphviz folder and copy its path and save it in notepad
In graphviz look for the bin folder and copy the folder by right click of your mouse
now again head back to my computer and search for "pydotplus"
a folder named pydotplus is displayed. Open it and paste the copy of bin folder (of Graphviz) that you copied earlier
head to control panel>system and security> system settings> advanced settings> environmental variables> add new path
add the path that you copied in notepad and click a series of "ok"
that's it now you can enjoy using graphviz
install Graphviz here and add its bin path solved my problem
https://graphviz.gitlab.io/_pages/Download/Download_windows.html
pip install Graphviz itself seems inadequate
Some things to know about graphviz:
graphviz is not only a python module, it's also a standalone program. I believe you need both to make graphviz to work.
The standalone graphviz program was originally developed by AT&T, open sourced, then abandoned. The current maintainers of the package forgot to include Windows registry entries so Python can find the program executable.
Line 620 of pydotplus\graphviz.py includes a backup path to look for graphviz if it isn't found in the registry. It uses the old ATT file path. Update the file path to what is on your machine (you will need to have administrator privileges) and graphviz should work with pydotplus.
Example:
# Just in case, try the default...
path = r"C:\Program Files (x86)\Graphviz2.38\bin"
In "pydot.py" (located in ...\Anaconda3\Lib\site-packages), replace:
def get_executable_extension():
# type: () -> str
if is_windows():
return '.bat' if is_anacoda() else '.exe'
else:
return ''
with:
def get_executable_extension():
# type: () -> str
if is_windows():
return '.exe'
else:
return ''
There does not seem to be any eason to add ".bat" when the system is "Windows/Anaconda" vs "Windows" and there may be no ".bat" associated with the ".exe". This seems better than adding a ".bat" for every executable pydot calls...
I had this issue and noticed that it was printing my PATH with two sets of double-quotes. I worked around the problem by adding the following to Line 1959 of:
C:\Anaconda\Lib\site-packages\pydot.py
self.progs[prog] = os.path.normpath(self.progs[prog][1:-1])
Obviously not the best fix but it got me through the day.
I found a manual solution:
sudo apt-get install graphviz
graph.write('test.dot')
dot -Tps test.dot -o outfile.ps
You can the files here: https://github.com/jecs89/LearningEveryDay/tree/master/GP
Tried all installation sequence as described in all solutions/posting/blogs, finally realized anaconda was not able to read the Environment variables. Closed Anaconda and Spyder. Then opened Anaconda in Administrator mode (on Windows 64 bit OS machine) and then opened Spyder. Script worked fine with PYDOT calls.
I am not using a windows machine, I am on a linux platform. I ran across this executable-not-found issue in the context of using the python package pyAgrum for plotting bayesian networks. pyAgrum uses graphviz to plot the networks. I installed pyagrum and graphviz using the anaconda platform in a python 3.6.4 environment (i.e. conda install <package name>).
I found the executables in /conda/envs/<environment name>/bin directory. So, it was just a matter of getting my notebook kernel to find them.
If you import os, use the command os.environ['PATH'].split(os.pathsep) to see the executable paths in which your environment is looking. If the path containing your graphviz executables isn't in there, you can add it by doing the following: os.environ['PATH'] += os.pathsep + <path to executables>.
I imagine this solution will work outside of my context. The main downside to this solution is that you need to do it every time you restart the kernel.
you can use pydotplus instead of pydot.then follow the belows:
First, find C:\Users\zhangqianyuan\AppData\Local\Programs\Python\Python36\Lib\site-packages\pydotplus
Second, open graphviz.py
Third, find line 1925 - line 1972, find the function def create(self, prog=None, format='ps'):
Final, in the function:
find:
if prog not in self.progs:
raise InvocationException(
'GraphViz\'s executable "%s" not found' % prog)
`
if not os.path.exists(self.progs[prog]) or \
not os.path.isfile(self.progs[prog]):
raise InvocationException(
'GraphViz\'s executable "{}" is not'
' a file or doesn\'t exist'.format(self.progs[prog])
)
between the two blocks add this(Your Graphviz's executable path):
self.progs[prog] = "C:/Program Files (x86)/Graphviz2.38/bin/gvedit.exe"
after adding the result is:
if prog not in self.progs:
raise InvocationException(
'GraphViz\'s executable "%s" not found' % prog)
self.progs[prog] = "C:/Program Files (x86)/Graphviz2.38/bin/gvedit.exe"
if not os.path.exists(self.progs[prog]) or \
not os.path.isfile(self.progs[prog]):
raise InvocationException(
'GraphViz\'s executable "{}" is not'
' a file or doesn\'t exist'.format(self.progs[prog])
)
save the changed file then you can run it successfully.
you'd better save it as bmp file because png file will not work.
If you dont want to mess around with path variables (e.g. if you are no admin) and if you are working on windows, you can do the following which solved the problem for me.
Open graphviz.py (likely located in ...Anaconda\pkgs\graphviz***\Library\bin) in an editor. If you cant find it you might be able to open it via the error message.
Go to the fuction __find_executables and replace:
elif os.path.exists(os.path.join(path, prg + '.exe')):
if was_quoted:
progs[prg] = '"' + os.path.join(path, prg + '.exe') + '"'
else:
progs[prg] = os.path.join(path, prg + '.exe')
with
elif os.path.exists(os.path.join(path, prg + '.bat')):
if was_quoted:
progs[prg] = '"' + os.path.join(path, prg + '.bat') + '"'
else:
progs[prg] = os.path.join(path, prg + '.bat')
The solution is easy, you just need to download and install the Graphviz, from here.
Then set the path variable to the bin directory, in my case it was C:\Program Files (x86)\Graphviz2.38\bin. Last, do the conda install python-graphviz and it should work fine.
On Anaconda distro, pip install did not work. I did a pip uninstall graphviz, pip uninstall pydot, and then I did conda install graphviz and then conda install pydot, in this order, and then it worked!
I used conda install python-graphviz
then
conda install pydot
and then
conda install pydot plus
and then it worked.
So:
conda install python-graphviz
conda install pydot
conda install pydotplus
after doing all the installation of graphviz, adding to the PATH of environment variables, you need to add these two lines:
import os
os.environ["PATH"] += os.pathsep + 'C:/Program Files (x86)/Graphviz2.38/bin/'
I tried several ways and all failed on Windows 10 and finally this worked for me:
Try to install it directly from graphviz website, just google "install graphviz" and I believe it will be the first option.

Resources